Discovering Internal Neural Features in Large Language Models: Methods and Engineering Practices

    This article explains what internal neural features are in large language models and why they matter for interpretability. It covers why neurons rarely map to a single concept due to superposition and polysemanticity, then surveys methods for locating features, including linear probes, clustering, PCA/ICA, functional interventions, and sparse autoencoders. It walks through training a sparse autoencoder to disentangle candidate features, applying activation steering to control model output, and building a reusable feature analysis pipeline that spans data collection, storage, feature indexing, and drift alerting. It also outlines suitable use cases such as safety alignment, model debugging, capability evaluation, and controllable generation, along with common pitfalls to avoid.

    Discovering Internal Neural Features in Large Language Models: Methods and Engineering Practices

    1. What Are Internal Neural Features, and How Do They Affect Model Interpretability?

    In the deep layers of a large language model, each layer is made up of a large number of activation dimensions. Internal neural features are not individual neurons themselves, but rather stable, reproducible combinations of internal activations that consistently appear when the model processes a certain type of concept, pattern, or task. They may correspond to entities, sentiments, styles, reasoning steps, or even signals related to output format. For developers, understanding these features matters because it turns “why did the model answer this way” from an empirical judgment into a measurable, comparable, and interventable engineering problem. However, feature analysis is only an entry point to interpretability; it does not mean the model is fully transparent.

    2. Why Don’t Neurons Map Directly to Concepts? Identifying Superposition and Polysemanticity

    A common misconception is that “one neuron corresponds to one concept.” In practice, the more common phenomenon is superposition: the model compresses a large number of concepts into a limited number of dimensions, so multiple semantic directions share the same set of neurons. This gives rise to polysemanticity: a single neuron may respond at the same time to mathematical symbols, natural language articles, or specific code structures. Identification methods usually include analyzing activation distributions, checking cross-task responses, comparing activations across different layers under the same prompt, and observing whether activations remain stable using a small number of contrast samples. If a single neuron appears frequently across different tasks, it should be treated as part of a superposed signal rather than a direct semantic unit.

    3. Beyond Sparse Autoencoders: Other Methods to Locate Features

    Common engineering alternatives include linear probes, clustering analysis, PCA or ICA, functional interventions, and sparse autoencoders. Linear probes are suitable for quickly determining whether a layer can linearly separate labels, but they struggle to disentangle polysemantic signals. Clustering can discover activation clusters, but cluster boundaries may not correspond to semantics. PCA or ICA can compress dimensions and highlight variance directions, but they offer weak interpretability and easily mix in irrelevant variables. Functional interventions validate causal effects by directly modifying activations; they are suitable for verifying key features but are costly. The advantage of sparse autoencoders is that they use a higher-dimensional hidden space or an overcomplete representation to split superposed activations into sparser candidate features. In real projects, a combined strategy works well: first use probes to locate candidate layers, then use sparse autoencoders to extract features, and finally use intervention experiments to validate them.

    4. How to Train a Sparse Autoencoder to Disentangle Candidate Features

    A sparse autoencoder takes the activations of a certain layer as input, maps them to a higher-dimensional hidden space, and constrains most hidden units to remain inactive, thereby splitting superposed signals into candidate features. The pseudocode below only illustrates the structure:

    1. # Pseudocode: Train a sparse autoencoder to disentangle the activations of a layer
    2. encoder = Linear(model_dim, hidden_dim)
    3. decoder = Linear(hidden_dim, model_dim)
    4. x_norm = normalize(x) # Normalize activations to avoid scale and dimensional effects on reconstruction
    5. pre_activation = encoder(x_norm) # Pre-activation
    6. activation = relu(pre_activation) # Hidden layer activation, retains sparse candidate features
    7. reconstruction = decoder(activation) # Reconstruct the original activations
    8. recon_loss = mse(reconstruction, x_norm) # Reconstruction loss
    9. sparse_loss = l1(pre_activation) # Sparsity penalty is usually applied to pre-activation or hidden activation
    10. loss = recon_loss + alpha * sparse_loss # alpha balances reconstruction quality against sparsity

    There are several key engineering points here. First, the hidden dimension is usually not simply equal to the model dimension; instead an overcomplete ratio is used, for example 4x, 8x, or higher. The higher the ratio, the more candidate features, but the higher the training and storage costs. Second, the sparsity penalty is usually applied to the hidden layer activation or the pre-activation, rather than directly to the final reconstruction result, otherwise reconstruction quality may suffer. Third, before training, fix the collection layer, the collection position, and the activation normalization method to avoid inconsistent data scales across different batches. Fourth, when tuning parameters, it is recommended to first keep the reconstruction loss within an acceptable range, then gradually increase the sparsity weight while observing the number of dead features, the reconstruction error, and feature interpretability. After training, each hidden dimension is only a candidate feature; it must still go through manual annotation, automatic labeling, activation frequency statistics, or intervention validation before it can be used as a trustworthy feature.

    5. How to Control Model Output with Activation Steering

    After discovering candidate features, you can further try activation steering, that is, enhancing or suppressing the activation of a certain direction during inference to guide the output toward being more cautious, more polite, or more compliant with norms. To make results reproducible, key variables must be fixed: fix the target layer and the injection position, fix the pooling method, fix the prompt sample distribution, and fix the batch size and decoding parameters. The process is usually as follows: first collect the activations of the same layer separately from positive samples and negative samples; perform mean pooling by position or by sentence; subtract the negative sample mean from the positive sample mean to obtain the steering vector; add it to the target layer activation at a certain ratio during inference; then check the effect and side effects on an independent evaluation set. Note that the steering vector is not a universal “concept switch”; it may be affected by prompt length, context task, and injection strength. It must be validated with an evaluation set, and the baseline, strength, random seed, and failure samples must be recorded.

    6. How to Build a Reusable Feature Analysis Pipeline

    Engineering implementation is not a one-off script, but a closed loop that runs from data collection to monitoring and alerting. You can start by building a minimum viable checklist. First, choose the layers. Prioritize collecting the middle layers of the model, or layers with stronger semantic abstraction, while keeping a small number of shallow and deep layers for comparison. Second, collect the tensor format. A common shape is [batch, seq_len, hidden]; it is recommended to save it as float16 or bfloat16, and to record the model version, prompt hash, layer number, position, and timestamp. Third, use object storage and access control. Large-scale activations can be stored by request ID, time window, or sharded files, with lifecycle policies, access control, and encryption configured to avoid unauthorized reads. Fourth, split the training set and validation set. Split by prompt source, task type, or document ID to prevent label leakage; it is recommended to have a clear ratio for training, validation, and held-out test, and to cover long-tail samples across different tasks. Fifth, set the sparse autoencoder training parameters. Record the hidden dimension, overcomplete ratio, learning rate, sparsity weight, batch size, number of training epochs, activation normalization method, and early stopping conditions. Sixth, build a feature retrieval index. Create a versioned index for the feature vectors that supports fast retrieval of relevant features by input; the index should include the version number, training data version, label source, and quality score. Seventh, define drift alerting metrics. You can monitor activation distribution shift, reconstruction error, dead feature ratio, feature hit frequency, top-k feature changes, as well as downstream evaluation metrics and safety evaluation metrics. These capabilities can be implemented using the object storage, containers, logging, and monitoring/alerting services of a general cloud platform, without being tied to a single product.

    7. Which Use Cases Fit, and How to Start at Low Cost?

    If you want to explain model anomalies, troubleshoot hallucinations, evaluate safety alignment, or implement fine-grained generation control, you can prioritize neural feature analysis. The applicable prerequisites include a clear evaluation set, a reproducible inference configuration, the ability to collect intermediate layer activations, and the ability to bear a certain amount of storage and training cost. The minimum-cost path is to first select a high-frequency failure scenario, collect a small number of samples, train a small-scale sparse autoencoder on one or two key layers, filter out features that can be manually interpreted, and then validate them with intervention experiments. Typical scenarios include safety alignment, model debugging, capability evaluation, and controllable generation. For safety alignment, you can identify features related to high-risk outputs and set suppression strategies. For model debugging, you can locate the responsible features. For capability evaluation, you can quantify the degree of knowledge mastery. For controllable generation, you can adjust tone and style through feature steering.

    8. Common Mistakes and Things to Watch Out For

    Common problems include: activations not normalized, leading to reconstruction bias; excessive sparsity, too many dead features, and degraded reconstruction quality; feature label leakage, where training and validation use samples from the same source and overestimate effectiveness; the index not being versioned, so features become misaligned with model versions; only counting activation frequency without intervention validation, which leads to unreliable explanations; steering strength set too high, causing output degradation or safety issues; and ignoring prompt distribution changes, which causes features to fail in real traffic. From an engineering standpoint, you should retain a baseline model, baseline evaluations, failure samples, and a rollback mechanism. Feature analysis is a process of approximating model behavior, not a final endpoint. A sound approach is to put feature discovery, manipulation experiments, evaluation alerting, and manual review into the same closed loop, which can improve interpretability, safety, and debugging governance.