export function getDatasetNameBasedOnNodeType()

in neuron_viewer/src/requests/paths.ts [25:53]


export function getDatasetNameBasedOnNodeType(nodeType: NodeType): string {
  // This function is used for explainerRequests and readRequests, which should only
  // use one autoencoder name. The autoencoder name is infered from the node type.
  if (
    nodeType === NodeType.AUTOENCODER_LATENT ||
    nodeType === NodeType.MLP_AUTOENCODER_LATENT ||
    nodeType === NodeType.ATTENTION_AUTOENCODER_LATENT ||
    nodeType === NodeType.AUTOENCODER_LATENT_BY_TOKEN_PAIR
  ) {
    // if there are multiple autoencoders, we need to use the full name to disambiguate
    const parts = getDatasetName().split("_");
    const modelName = parts[0];
    const autoencoderName = parts
      .slice(1)
      .find(
        (part) =>
          (nodeType === NodeType.AUTOENCODER_LATENT && part.includes("")) ||
          (nodeType === NodeType.MLP_AUTOENCODER_LATENT &&
            (part.includes("resid-delta-mlp") || part.includes("mlp-post-act"))) ||
          (nodeType === NodeType.ATTENTION_AUTOENCODER_LATENT &&
            part.includes("resid-delta-attn")) ||
          (nodeType === NodeType.AUTOENCODER_LATENT_BY_TOKEN_PAIR &&
            part.includes("resid-delta-attn"))
      );
    return `${modelName}_${autoencoderName}`;
  }
  // everything other than autoencoder should only use the first part of the dataset name, before the underscore
  return getFirstPartOfDatasetName();
}