LIME

28 min read
Updated
Suggest editHistoryTalk
RawGraph

Last edited

Fact-checked

In review queue

Sources

17 citations

Revision

v6 · 5,639 words

Fact-checks are independent of edits: a reviewer re-verifies the article against its sources and stamps the date. How we verify

LIME (Local Interpretable Model-Agnostic Explanations) is a technique for explaining individual predictions of any black-box machine learning classifier or regressor by approximating the model locally with a simple, interpretable surrogate. It was introduced by Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin in the 2016 paper "Why Should I Trust You?: Explaining the Predictions of Any Classifier," presented at the ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD) [1]. The authors describe it as "a novel explanation technique that explains the predictions of any classifier in an interpretable and faithful manner, by learning an interpretable model locally around the prediction" [1]. Within a few years it became one of the most widely cited tools in explainable AI, helping practitioners debug models, audit fairness, and satisfy regulatory demands for algorithmic transparency. The method works by perturbing the input around a single prediction, recording how the model's output shifts, and fitting a sparse linear model (or another simple surrogate) to those perturbations [1]. Because LIME treats the underlying model as a black box and only needs query access to its inputs and outputs, it is genuinely model-agnostic and applies to neural networks, random forests, gradient-boosted trees, support vector machines, and any other predictor.

ELI5 (explain like I'm 5)

Imagine a magic box that looks at a photo and says "cat" or "dog." You want to know why the box said "cat." So you start covering up bits of the photo with paper. When you cover the ears and the box suddenly says "dog," you learn that the ears were carrying the "cat" answer. LIME does roughly the same thing. It hides or changes small parts of the input, watches how the answer wobbles, then writes down which parts moved the needle the most.

Why was LIME created?

As models grew from logistic regressions with a handful of features into deep neural networks with millions of parameters and stacked tree ensembles with thousands of estimators, they also grew opaque. A model can hit 99 percent accuracy on a held-out test set and still be making decisions for completely wrong reasons. The 2016 paper opens with the now-famous example of a 20 Newsgroups random forest that separated "Christianity" from "Atheism" posts at 92.4 percent test accuracy by latching onto email headers like "Posting-Host" and "NNTP-Posting-Host" rather than the religious content of the messages [1][14]. Without an explanation tool, that data leakage would have shipped to production.

Three pressures made local explanations valuable around the time LIME appeared:

  • Trust. Domain experts in medicine, finance, and criminal justice will not act on a model's recommendation unless they understand the reasoning behind it [1].
  • Debugging. Models that lean on spurious correlations such as image watermarks, scanner artifacts, or formatting tokens often fail when those shortcuts disappear.
  • Regulation. The EU's General Data Protection Regulation (GDPR), in force from 2018, restricts purely automated decisions that have legal or similarly significant effects (Article 22) and requires "meaningful information about the logic involved" under Articles 13 to 15 [13]. Later regulation, including the EU AI Act, extended these obligations to high-risk AI systems.

Before LIME, most interpretability tools were either model-specific (reading the weights of a logistic regression, inspecting decision paths in a decision tree) or only global (averaged variable importances across the whole dataset). LIME staked out the middle ground: instance-level explanations that work on any model [1].

Who created LIME and when?

The paper was written while Ribeiro was a PhD student at the University of Washington, advised by Carlos Guestrin and collaborating with Sameer Singh, who is now a professor at UC Irvine. Ribeiro later joined Microsoft Research and then Microsoft AI in Seattle, where he continued to publish on model debugging, behavioral testing (the CheckList paper at ACL 2020), and interactive ML.

The paper was uploaded to arXiv on 16 February 2016 as preprint 1602.04938 and presented at KDD 2016 in San Francisco that August, where it received the audience appreciation award [1][14]. By the mid 2020s it had accumulated over 15,000 citations on Google Scholar, placing it among the most cited papers in machine learning interpretability; the arXiv citation tracker alone recorded 21,343 citing works as of January 2025 [16].

What do the three parts of the name mean?

The acronym encodes three design goals.

PropertyMeaning
LocalExplanations describe the model's behavior in a small neighborhood around one prediction, not the whole input space. A black-box model may behave very differently in different regions, and local fidelity is far more achievable than global fidelity. The authors note an explanation "should correspond to how the model behaves in the vicinity of the instance being predicted" [1].
InterpretableThe explanation must be readable by a human. LIME uses inherently interpretable representations: binary indicators for word presence, binary masks over image superpixels, discretized bins for tabular features [1].
Model-agnosticLIME never inspects gradients, weights, or architecture. It only queries the model with arbitrary inputs and reads the outputs, so the same code can explain a logistic regression, a random forest, or a 175-billion parameter language model [1].

In the authors' words, "the overall goal of LIME is to identify an interpretable model over the interpretable representation that is locally faithful to the classifier" [1].

How does LIME work?

The core procedure has five steps [1].

  1. Pick the instance x to explain. This might be a single row in a tabular dataset, a sentence, or an image.
  2. Generate perturbed samples around x. The perturbation strategy depends on the data type.
  3. Query the black-box model on each perturbation to get its predicted probability or score.
  4. Weight each perturbed sample by its proximity to x using an exponential kernel, so points near the original count for more.
  5. Fit a sparse, weighted, interpretable surrogate (typically a linear model) on the perturbed samples and their black-box predictions. The surrogate's coefficients are the explanation.

The interpretable representation used inside LIME is usually a binary vector. For text, each dimension is one if the word is present and zero if removed. For images, each dimension is one if a superpixel is shown and zero if grayed out. For tabular data, each dimension corresponds to a discretized bin. The surrogate model lives in this binary space, but the predictions it tries to match come from the model evaluated on the actual perturbed input [1].

What perturbation does LIME use for each data type?

Data typeInterpretable representationPerturbation methodDistance metric
TabularDiscretized feature bins, often quartiles for continuous features and original categories for categorical onesSample new values from a normal distribution fitted to the per-feature mean and standard deviation of the training data, or sample from the empirical distributionEuclidean distance on the scaled feature vector
TextBinary vector indicating presence or absence of each token in the original documentRandomly drop tokens from the text, replacing them with an empty string or a placeholderCosine distance, or one minus the fraction of tokens retained
ImageBinary vector indicating whether each superpixel is on or offSegment the image into superpixels using quickshift (default), SLIC, or felzenszwalb from scikit-image, then randomly turn superpixels off by replacing their pixels with a fixed color (gray) or the mean RGB valueCosine distance on the binary superpixel vector

What is the math behind LIME?

LIME poses the explanation as an optimization problem that balances local fidelity against simplicity [1]:

explanation(x)=argmingGL(f,g,πx)+Ω(g)\text{explanation}(x) = \arg\min_{g \in G} L(f, g, \pi_x) + \Omega(g)

The terms are:

  • f, the black-box model.
  • g, a candidate interpretable model drawn from a family G such as linear models, short decision trees, or sparse rule lists.
  • L(f, g, pi_x), a loss measuring how unfaithfully g approximates f in the locality defined by pi_x.
  • pi_x, a proximity kernel that defines the neighborhood around x.
  • Omega(g), a complexity penalty on g, often the number of nonzero coefficients in a sparse linear model.

For sparse linear surrogates, the loss is locally weighted squared error:

L(f,g,πx)=z,zZπx(z)(f(z)g(z))2L(f, g, \pi_x) = \sum_{z, z' \in Z} \pi_x(z) (f(z) - g(z'))^2

Here z is a perturbed sample in the original feature space, z' is its binary interpretable representation, and Z is the set of generated perturbations.

The proximity kernel is exponential:

πx(z)=exp(D(x,z)2/σ2)\pi_x(z) = \exp(-D(x, z)^2 / \sigma^2)

where D is a distance function (Euclidean for tabular, cosine for text and images) and sigma is a kernel width. The reference Python implementation defaults to σ=0.75number_of_features\sigma = 0.75 \sqrt{\text{number\_of\_features}}, a value whose origin is not justified theoretically and which has become one of the most criticized aspects of the package [10][15].

How does LIME keep explanations short?

To keep the surrogate readable, LIME restricts it to at most K nonzero features. The reference implementation runs a LASSO regression with a decreasing regularization parameter and stops when exactly K features have entered the model (the so-called regularization path). Other supported feature selection strategies include forward selection and selecting the K features with the largest absolute weights from a non-sparse fit [15].

What are the variants of LIME?

The official Python package ships three classes that wrap the same core algorithm.

VariantClassTypical use caseNotes
LIME-TabularLimeTabularExplainerCredit scoring, fraud, churn, medical riskRequires the training dataset to fit per-feature statistics. Categorical features are passed via categorical_features and categorical_names.
LIME-TextLimeTextExplainerSentiment analysis, spam detection, topic classificationTokenizes the document with a regex by default and explains in terms of word presence. Includes a built-in HTML visualizer that highlights influential words inline.
LIME-ImageLimeImageExplainerImage classification debugging, medical imagingUses scikit-image segmentation (quickshift by default; SLIC or felzenszwalb optional) to define superpixels, then perturbs by graying out subsets.

A fourth construct in the same library is SP-LIME (submodular pick), which selects a small set of instances whose individual explanations together give a global picture [1].

What is SP-LIME (submodular pick)?

Individual LIME explanations are local. Practitioners often need a global view, but generating an explanation for every instance is impractical and most explanations would be redundant. SP-LIME frames instance selection as a submodular optimization problem [1].

Formal definition

SP-LIME builds an explanation matrix W of size n by d', where n is the number of candidate instances and d' is the number of interpretable features. Entry W_ij is the absolute weight that feature j received in the LIME explanation for instance i:

Wij=wgi,jW_{ij} = |w_{g_i, j}|

A global importance vector I summarizes how representative each feature is across explanations:

Ij=i=1nWijI_j = \sqrt{\sum_{i=1}^{n} W_{ij}}

The coverage of a candidate set V of selected instances is the total importance of features that appear in at least one of those instances' explanations:

c(V,W,I)=j=1d1[iV:Wij>0]Ijc(V, W, I) = \sum_{j=1}^{d'} \mathbf{1}_{[\exists\, i \in V : W_{ij} > 0]} \cdot I_j

The pick problem is to choose at most B instances that maximize coverage:

Pick(W,I)=argmaxV,VBc(V,W,I)\text{Pick}(W, I) = \arg\max_{V, |V| \le B} c(V, W, I)

Greedy algorithm

Maximizing coverage is NP-hard, but the function c is monotone submodular, so the standard greedy algorithm gives a (11/e)(1 - 1/e), or roughly 63 percent, approximation guarantee [1]. The procedure is:

  1. Start with an empty set V.
  2. For every candidate instance not yet in V, compute the marginal coverage gain of adding it.
  3. Add the instance with the largest marginal gain.
  4. Repeat until |V| equals the budget B.

In the original paper, SP-LIME outperformed random sampling for small budgets. Trust assessments based on SP-LIME-selected examples were a much better predictor of the model's true generalization than the same number of randomly chosen explanations [1].

Worked example: husky vs wolf

The husky-versus-wolf experiment is the canonical illustration of why local explanations matter. Ribeiro and his coauthors deliberately built a bad classifier: a logistic regression on features from Google's pre-trained Inception neural network, trained on a hand-curated set of 20 images in which every wolf photo had snow in the background and every husky photo did not [1]. Evaluated on a separate set of 60 images, the classifier predicted "wolf" whenever the lower portion of the image was snowy and "husky" otherwise, regardless of the animal's color, pose, or position. LIME explanations revealed that the classifier had learned almost nothing about the animals themselves and was keying on the snowy background.

The authors then ran a small user study with 27 graduate students who had taken at least one machine learning course. Before seeing explanations, 10 of 27 trusted the classifier and only 12 of 27 mentioned snow as a potential feature the network was using. After being shown LIME explanations, only 3 of 27 still trusted the classifier and 25 of 27 identified snow as the cue the model was relying on [1]. The experiment is now a standard teaching example for spurious correlations, dataset bias, and the difference between accuracy and validity.

Worked example: 20 Newsgroups

In the same paper, a random forest with 500 trees trained on the 20 Newsgroups corpus to distinguish Christianity posts from Atheism posts hit 92.4 percent test accuracy [14]. LIME explanations highlighted features such as "Posting," "Host," "Re," and "NNTP," almost none of which carry semantic meaning about religion [1][14]. The classifier was exploiting metadata from email headers that happened to correlate with class labels in this particular collection. The paper also reports that a classifier trained the same way scored only 57.3 percent on a real-world religion dataset, while a "cleaned" version that LIME helped strip of leaky features did substantially better in the wild [1]. The example became a textbook case of leakage in academic NLP datasets.

How does LIME compare to SHAP?

SHAP (SHapley Additive exPlanations), introduced by Scott Lundberg and Su-In Lee in 2017, is the most direct successor in the same family of local, model-agnostic explanation methods [3]. The two share design goals but differ in foundations and trade-offs.

AspectLIMESHAP
Theoretical basisLocally weighted surrogate model fit to perturbationsShapley values from cooperative game theory
Explanation scopeLocal only (SP-LIME bolts on a global view)Local, with principled global aggregations
ConsistencyNot guaranteed; reruns can yield different attributionsSatisfies local accuracy, missingness, and consistency axioms
SpeedFast for low-dimensional inputs; per-instance cost grows with the number of perturbationsExact computation is exponential in features; KernelSHAP is similar to LIME in cost; TreeSHAP is polynomial for tree ensembles
Feature interactionsNot captured by the linear surrogateCaptured via Shapley interaction values
AdditivityCoefficients do not have to sum to the predictionAttributions sum exactly to f(x) minus the expected value
Hyperparameter sensitivityHighly sensitive to kernel width, sample count, and KFewer hyperparameters; more deterministic outputs
Model-specific optimizationsNoneTreeSHAP, DeepSHAP, LinearSHAP
Typical use todayQuick, exploratory, or low-stakes explanationsDefault for production tabular interpretability

The original SHAP paper showed that LIME, DeepLIFT, and several other methods can be unified as special cases of "additive feature attribution methods," and that LIME's choice of weighting function and loss does not satisfy the Shapley axioms; KernelSHAP recovers LIME's framework with a specific kernel that does [3]. In practice, SHAP has displaced LIME as the default for tabular interpretability in industry tooling, while LIME survives mainly for text and image use cases or as a quick first pass.

How does LIME compare to other explanation methods?

MethodFamilyModel accessOutputStrengthWeakness
LIMELocal surrogateBlack box (predict only)Sparse linear weights over interpretable featuresWorks on any model, fast for low dimensions, easy to readUnstable, sensitive to kernel width and sampling
SHAPShapley valuesBlack box (KernelSHAP) or model-specific (TreeSHAP, DeepSHAP)Additive attributions per featureTheoretical guarantees, additiveSlow in the model-agnostic case
Integrated GradientsGradient basedWhite box, requires differentiable modelPer-feature attribution along a baseline-to-input pathSatisfies completeness and sensitivity axioms, fastNeeds gradients, requires a baseline choice
Grad-CAMActivation mapWhite box, convolutional networksHeatmap over feature map locationsFast, visually intuitive for CNNsLimited to convolutional architectures
Permutation importanceGlobal feature importanceBlack boxDrop in performance when a feature is shuffledSimple, model-agnostic, globalNo instance-level view, mishandles correlated features
AnchorsRule basedBlack boxIF-THEN rule with coverage and precisionExplicit boundaries, easy to verifyCoarse for high-dimensional inputs

For smooth differentiable models, LIME's superpixel attribution and the sum of integrated gradients over the same superpixel converge in expectation, giving a theoretical link between perturbation-based and gradient-based methods.

What are the limitations of LIME?

Instability of explanations

LIME relies on random perturbation sampling, so two runs on the same instance can yield different attributions [7]. Empirical studies have shown that explanations for two nearly identical inputs can disagree on which features matter most. This nondeterminism is one of the strongest objections to using LIME as evidence in regulatory or auditing settings.

Choice of neighborhood

The kernel width sigma controls how local the explanation is, and there is no principled way to pick it. Different values can produce contradictory explanations for the same instance. Christoph Molnar, author of the open-source book Interpretable Machine Learning, writes that the choice of neighborhood is "the biggest problem with LIME and the reason why I would recommend using LIME only with great care," advising practitioners to try several kernel widths and check the explanations for consistency [10]. The default value of 0.75d0.75 \sqrt{d} is a heuristic with no clear theoretical basis.

Feature correlation

The default tabular perturbation samples each feature independently from a normal distribution. This ignores correlations between features and routinely produces unrealistic synthetic samples (a 30 kg adult who is 2 meters tall, a credit card transaction with a negative amount, an image where pixel intensities are wildly inconsistent). The black-box model is then queried on inputs from a distribution it was never trained on, and the resulting explanations may not reflect anything the model actually does on real data [10].

Linear surrogate

LIME's surrogate is usually a sparse linear model. If the black-box model is highly nonlinear in the local neighborhood, no linear approximation can be faithful. Interaction effects between features are invisible by construction.

Sampling bias and out-of-distribution queries

Because perturbations are generated synthetically rather than drawn from the data manifold, the black-box model is evaluated on inputs that may be out of distribution. For high-dimensional images or long documents, the perturbed inputs are often visibly broken (an image with random patches grayed out, a sentence with random words removed), and the model's behavior on these is not necessarily indicative of its behavior on real inputs.

Adversarial vulnerability

In 2020, Dylan Slack, Sophie Hilgard, Emily Jia, Sameer Singh, and Himabindu Lakkaraju showed at the AAAI/ACM Conference on AI, Ethics, and Society that an attacker can construct an adversarial classifier that behaves discriminatorily on real data and benignly on the perturbations LIME generates [4]. The trick is a scaffolding model that detects whether the input is real or synthetic, returns the biased prediction in the former case and an innocuous one in the latter. LIME (and to a lesser extent SHAP) then reports a clean explanation while the deployed model continues to discriminate. The paper used the COMPAS recidivism dataset and showed that explanations could be made arbitrary while accuracy on real data was unchanged [4].

Hyperparameter and segmentation sensitivity

Beyond the kernel width, LIME requires the user to set the number of features K, the number of perturbations, the distance metric, and (for images) the segmentation algorithm and its parameters. Each of these choices changes the output. There is little practical guidance and almost no automated tuning support in the reference package.

Scalability

A typical LIME explanation queries the model thousands of times. For large language models or expensive computer vision pipelines, this is slow and costly. Batching helps but does not change the asymptotic cost.

What methods improve on LIME?

The limitations above have driven a long line of follow-up work, much of it from the same research community.

MethodYearImprovement over LIME
SHAP2017Theoretically grounded Shapley attributions with consistency, local accuracy, and missingness guarantees [3]
Anchors2018Same authors as LIME; produces high-precision IF-THEN rules with explicit coverage instead of linear surrogates [2]
DLIME2019Replaces random perturbation with hierarchical clustering plus k-nearest neighbors, producing deterministic explanations on healthcare datasets [5]
BayLIME2021Adds Bayesian inference over surrogate weights to give uncertainty intervals on each attribution [6]
OptiLIME2021Automates kernel width selection by optimizing for stability of the explanation
GLIME2023Generalizes LIME under a unified framework that recovers KernelSHAP and other variants [8]
US-LIME2024Replaces random perturbation with uncertainty sampling to improve fidelity on tabular data
BMB-LIME2024Extends the surrogate beyond linear models to handle local nonlinearity and uncertainty

Anchors, introduced by Ribeiro, Singh, and Guestrin at AAAI 2018, is the most direct successor and is often described by its authors as a remedy for several LIME failure modes [2]. Instead of a linear approximation that holds locally with no stated boundary, anchors produce conditional rules of the form "IF word 'excellent' is present AND word 'awful' is absent THEN positive sentiment, with precision 0.97 and coverage 0.18." The rule explicitly states the conditions under which it holds and the fraction of inputs it covers, so users know when to apply it.

Where can I get LIME (implementations)?

The reference Python package (lime on PyPI, marcotcr/lime on GitHub) is maintained by Ribeiro and exposes LimeTabularExplainer, LimeTextExplainer, LimeImageExplainer, and submodular_pick. It is open source under the BSD-2-Clause license and has more than 11,000 stars on GitHub [15].

PackageLanguageDescription
limePythonThe original implementation. Install with pip install lime. Ships LimeTabularExplainer, LimeTextExplainer, LimeImageExplainer, and submodular_pick.
lime (R)RR port maintained by Thomas Lin Pedersen, available on CRAN.
imlRChristoph Molnar's general interpretability package; includes a LIME variant called LocalModel.
DALEXR, PythonModel exploration toolkit from Przemyslaw Biecek's group; wraps LIME alongside breakdown, ceteris paribus, and other methods.
InterpretMLPythonMicrosoft's interpretability toolkit; includes LIME alongside SHAP, explainable boosting machines, partial dependence, and morris sensitivity [12].
eli5PythonLibrary for debugging and explaining classifiers; supports LIME-style explanations for text classifiers.
alibiPythonSeldon's interpretability library; includes Anchors, integrated gradients, counterfactuals, and a LIME-compatible interface [11].
CaptumPythonPyTorch interpretability toolkit; primarily gradient-based but ships an Occlusion baseline that resembles LIME-Image for vision models.
SkaterPythonOlder interpretability toolkit (now mostly unmaintained) that bundled LIME, partial dependence, and feature importance.

Basic Python usage

A minimal example using LIME with scikit-learn:

import lime
import lime.lime_tabular
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris

iris = load_iris()
rf = RandomForestClassifier(n_estimators=100, random_state=0)
rf.fit(iris.data, iris.target)

explainer = lime.lime_tabular.LimeTabularExplainer(
    training_data=iris.data,
    feature_names=iris.feature_names,
    class_names=iris.target_names,
    mode='classification',
)

exp = explainer.explain_instance(
    data_row=iris.data[0],
    predict_fn=rf.predict_proba,
    num_features=4,
    num_samples=5000,
)

exp.show_in_notebook()

For text classification, LimeTextExplainer takes a callable that maps a list of strings to a probability matrix:

from lime.lime_text import LimeTextExplainer
from sklearn.pipeline import make_pipeline
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression

pipeline = make_pipeline(TfidfVectorizer(), LogisticRegression())
pipeline.fit(train_texts, train_labels)

explainer = LimeTextExplainer(class_names=['neg', 'pos'])
exp = explainer.explain_instance(
    test_texts[0],
    pipeline.predict_proba,
    num_features=10,
)
exp.show_in_notebook()

For images, LimeImageExplainer accepts a callable returning class probabilities for a batch of images:

from lime.lime_image import LimeImageExplainer
from skimage.segmentation import slic

explainer = LimeImageExplainer()
exp = explainer.explain_instance(
    image,
    classifier_fn=model.predict,
    top_labels=5,
    hide_color=0,
    num_samples=1000,
    segmentation_fn=lambda x: slic(x, n_segments=50, compactness=10),
)
image_with_mask, mask = exp.get_image_and_mask(
    label=exp.top_labels[0], positive_only=True, num_features=5,
)

What is LIME used for in practice?

Healthcare

LIME has been applied to chest X-ray classifiers, retinal screening models, histopathology models, and Alzheimer's disease detection from MRI. Clinicians use the highlighted regions to check whether the model attends to clinically relevant anatomy or to artifacts such as scanner watermarks, image borders, or device-specific noise. The deterministic variant DLIME was developed specifically because instability in standard LIME explanations made it hard to deploy in computer-aided diagnosis [5]. A 2024 review in PMC catalogs dozens of LIME applications in Alzheimer's research alone.

The landmark Esteva et al. 2017 Nature paper on dermatologist-level skin cancer classification used t-SNE to visualize learned features rather than LIME, but follow-up dermatology research has applied LIME to similar models to understand which lesion regions and color patterns contribute to malignancy predictions [9]. Stieler and colleagues, for example, embedded the dermatological ABCD rule (asymmetry, border, color, diameter) inside LIME to align machine explanations with clinical heuristics.

Finance

Banks use LIME to explain individual credit decisions, both internally for risk officers and externally for adverse-action notices required under regulations such as the US Equal Credit Opportunity Act. It is also used for transaction-level explanations in fraud detection and anti-money-laundering systems, where investigators need to understand why a particular transaction was flagged.

Criminal justice and fairness auditing

Researchers have used LIME to probe risk-assessment tools such as COMPAS for racial bias. The Slack et al. 2020 attack on LIME used the COMPAS dataset directly, both as a demonstration that biased classifiers can hide behind LIME explanations and as a warning to auditors who rely on LIME alone [4].

Computer vision debugging

Beyond the husky-wolf example, LIME has been used to find spurious cues in image classifiers, such as background context (grass for cows, sand for camels), watermarks left over from web scraping, capture-device artifacts in medical imaging, and hospital-specific tags burnt into X-ray corners. In 2017 a widely shared analysis of a pneumonia classifier showed that the model had learned to detect the portable X-ray scanner used in intensive care units, not pneumonia itself; LIME-style superpixel masks were one of the tools used to make this visible.

Natural language processing

LIME-Text is used to debug sentiment classifiers, spam filters, toxicity detectors, and clinical NLP systems. A common finding is that classifiers trained on user-generated text rely heavily on stylistic markers (punctuation, capitalization, specific function words) rather than content. Recent work has applied LIME to transformer-based models such as BERT, although as model size grows the alignment between LIME explanations and the model's internal computations weakens, suggesting that LIME captures input-level salience rather than mechanistic reasoning in large models.

Is LIME still used with large models?

The interpretability landscape has shifted since 2016. For tabular data, SHAP has largely displaced LIME because of its theoretical guarantees and its highly optimized TreeSHAP implementation [3]. For image classifiers, gradient-based methods such as Grad-CAM, Integrated Gradients, and SmoothGrad are usually faster and produce smoother heatmaps than LIME's superpixel masks; LIME-Image is most useful when the model is genuinely a black box and gradients are unavailable. For text classifiers and especially for transformer language models, LIME-Text still works but is one of several options that includes attention attribution, integrated gradients on token embeddings, and feature ablation.

A different paradigm, mechanistic interpretability, has emerged for understanding large language models. Where LIME asks "which input features moved this prediction," mechanistic interpretability asks "which internal circuits implement this behavior." Anthropic's work on monosemantic features in Claude, Neel Nanda's TransformerLens library, and the broader sparse autoencoder literature pursue questions about mid-network computation that post-hoc methods such as LIME are not designed to answer. The two paradigms address different questions and are complementary rather than competing.

Research from 2024 examined how LIME explanations vary with LLM size and found that bigger models do not produce more plausible LIME explanations, suggesting the local linear surrogate captures something other than the model's internal reasoning as the model grows.

How should you use LIME reliably (best practices)?

Practitioners who continue to use LIME generally follow a small set of rules of thumb.

  • Run the explainer multiple times with different random seeds and check that the top features are stable. If they are not, the explanation is unreliable [7].
  • Tune the kernel width or use a variant such as OptiLIME that selects sigma automatically. Do not rely on the default 0.75d0.75 \sqrt{d} without checking it [10].
  • For tabular data, prefer a sampling strategy that respects feature correlation (for example, a generative model fitted to the training data) over the default independent normal perturbation.
  • For text and images, increase num_samples to several thousand for stable explanations; the default is too low for high-dimensional inputs.
  • Use SP-LIME or a similar pick procedure to avoid drawing global conclusions from a handful of cherry-picked instances [1].
  • Validate explanations against domain knowledge. A LIME explanation that contradicts what a clinician or analyst expects is a hypothesis to investigate, not a conclusion.
  • For high-stakes deployments, treat LIME as one signal among many. Combine it with SHAP, counterfactuals, Anchors, and direct inspection of training data rather than relying on any single explanation tool.
  • Be aware of the Slack et al. 2020 result. LIME explanations alone cannot certify fairness; they can only identify candidate problems for further investigation [4].

How influential has LIME been?

The original LIME paper has accumulated more than 15,000 citations on Google Scholar by the mid 2020s and is one of the most cited papers in the explainable AI literature; the arXiv citation tracker recorded 21,343 citing works as of January 2025 [16]. The Python package on GitHub has more than 11,000 stars and remains in active maintenance [15]. LIME helped establish post-hoc local explanation as a mainstream subfield of machine learning research and influenced regulatory thinking about algorithmic transparency in the EU and elsewhere [13]. It is taught in essentially every introductory interpretability course and ships as a default option in major MLOps platforms.

Its most lasting contribution may be conceptual rather than algorithmic. The husky-versus-wolf example reframed the question of model trust from "is the test accuracy high" to "is the model attending to the right features," and it made the answer accessible to non-machine-learning experts [1]. The follow-up literature, including SHAP, Anchors, and the entire model-agnostic explanation toolkit, builds on the framing LIME introduced.

See also

References

  1. Ribeiro, M. T., Singh, S., and Guestrin, C. (2016). "Why Should I Trust You?": Explaining the Predictions of Any Classifier. *Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining*, 1135 to 1144. arXiv:1602.04938.
  2. Ribeiro, M. T., Singh, S., and Guestrin, C. (2018). Anchors: High-Precision Model-Agnostic Explanations. *Proceedings of the AAAI Conference on Artificial Intelligence*, 32(1), 1527 to 1535.
  3. Lundberg, S. M., and Lee, S.-I. (2017). A Unified Approach to Interpreting Model Predictions. *Advances in Neural Information Processing Systems*, 30, 4765 to 4774.
  4. Slack, D., Hilgard, S., Jia, E., Singh, S., and Lakkaraju, H. (2020). Fooling LIME and SHAP: Adversarial Attacks on Post Hoc Explanation Methods. *Proceedings of the AAAI/ACM Conference on AI, Ethics, and Society*, 180 to 186. arXiv:1911.02508.
  5. Zafar, M. R., and Khan, N. M. (2019). DLIME: A Deterministic Local Interpretable Model-Agnostic Explanations Approach for Computer-Aided Diagnosis Systems. *ACM SIGKDD Workshop on Explainable AI/ML for Accountability, Fairness, and Transparency*. arXiv:1906.10263.
  6. Zhao, X., Huang, X., Robu, V., and Flynn, D. (2021). BayLIME: Bayesian Local Interpretable Model-Agnostic Explanations. *Proceedings of the 37th Conference on Uncertainty in Artificial Intelligence*.
  7. Visani, G., Bagli, E., Chesani, F., Poluzzi, A., and Capuzzo, D. (2022). Statistical stability indices for LIME: Obtaining reliable explanations for machine learning models. *Journal of the Operational Research Society*, 73(1), 91 to 101.
  8. Tan, Z., Tian, Y., and Li, J. (2023). GLIME: General, Stable and Local LIME Explanation. *Advances in Neural Information Processing Systems*, 36.
  9. Esteva, A., Kuprel, B., Novoa, R. A., Ko, J., Swetter, S. M., Blau, H. M., and Thrun, S. (2017). Dermatologist-level classification of skin cancer with deep neural networks. *Nature*, 542, 115 to 118.
  10. Molnar, C. (2024). *Interpretable Machine Learning: A Guide for Making Black Box Models Explainable* (3rd ed.). Online book, christophm.github.io/interpretable-ml-book.
  11. Klaise, J., Van Looveren, A., Vacanti, G., and Coca, A. (2021). Alibi Explain: Algorithms for Explaining Machine Learning Models. *Journal of Machine Learning Research*, 22(181), 1 to 7.
  12. Nori, H., Jenkins, S., Koch, P., and Caruana, R. (2019). InterpretML: A Unified Framework for Machine Learning Interpretability. arXiv:1909.09223.
  13. Edwards, L., and Veale, M. (2017). Slave to the Algorithm? Why a 'Right to an Explanation' Is Probably Not the Remedy You Are Looking For. *Duke Law and Technology Review*, 16, 18 to 84.
  14. Ribeiro, M. T. (2016). LIME: Local Interpretable Model-Agnostic Explanations. Blog post, University of Washington. homes.cs.washington.edu/~marcotcr/blog/lime/.
  15. marcotcr/lime. GitHub repository. github.com/marcotcr/lime.
  16. arXiv. "Why Should I Trust You?": Explaining the Predictions of Any Classifier, citation record (1602.04938). arxiv.org/abs/1602.04938.

Improve this article

Add missing citations, update stale details, or suggest a clearer explanation. Every suggestion is reviewed for sourcing before it goes live.

5 revisions by 1 contributors · full history

Suggest edit