{"id":27400841,"url":"https://github.com/butanium/tiny-activation-dashboard","last_synced_at":"2026-05-03T05:44:33.809Z","repository":{"id":263521919,"uuid":"890484235","full_name":"Butanium/tiny-activation-dashboard","owner":"Butanium","description":"A tiny easily hackable implementation of a feature dashboard.","archived":false,"fork":false,"pushed_at":"2025-09-17T14:19:56.000Z","size":130,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-25T07:51:29.210Z","etag":null,"topics":["feature-dashboard","feature-visualization","sparse-autoencoder","sparse-autoencoders"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Butanium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-18T16:40:29.000Z","updated_at":"2025-09-17T14:20:00.000Z","dependencies_parsed_at":"2025-04-14T03:44:06.039Z","dependency_job_id":"4e978979-c812-4b3a-aa91-f974979a3d4b","html_url":"https://github.com/Butanium/tiny-activation-dashboard","commit_stats":null,"previous_names":["butanium/tiny-activation-dashboard"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/Butanium/tiny-activation-dashboard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Butanium%2Ftiny-activation-dashboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Butanium%2Ftiny-activation-dashboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Butanium%2Ftiny-activation-dashboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Butanium%2Ftiny-activation-dashboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Butanium","download_url":"https://codeload.github.com/Butanium/tiny-activation-dashboard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Butanium%2Ftiny-activation-dashboard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32559716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T03:21:47.309Z","status":"ssl_error","status_checked_at":"2026-05-03T03:21:43.884Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["feature-dashboard","feature-visualization","sparse-autoencoder","sparse-autoencoders"],"created_at":"2025-04-14T03:43:24.490Z","updated_at":"2026-05-03T05:44:33.803Z","avatar_url":"https://github.com/Butanium.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tiny Activation Dashboard\nA tiny easily hackable implementation of a feature dashboard.\n## Installation\n\n```bash\npip install tiny-dashboard\n```\n\n## Overview\n\nThis repository provides minimal implementations of activations visualization with:\n- An online feature dashboard, where you compute and display activations on some custom text\n- An offline feature dashboard, which can display precomputed activation examples.\n\nTo get an overview of all the features you can check the [demo on colab](https://colab.research.google.com/github/Butanium/tiny-activation-dashboard/blob/main/demo.ipynb)!\n\nOnline dashboard demo:\n![image](https://github.com/user-attachments/assets/17d176bf-e8e5-471b-bbbf-dc3286f16907)\n\nOffline dashboard demo:\n![image](https://github.com/user-attachments/assets/74ab6d98-b10a-4894-a2a3-72f1f20ae7ac)\n\n\n## Motivation\n\nThere are some other good feature activations dashboard tools out there, but I found them very hard to hack on when I wanted to add support for Crosscoders. This implementation is not as complete as https://github.com/jbloomAus/SAEDashboard or even the simplier https://github.com/callummcdougall/sae_vis but in my honest non-biased-at-all opinion, this implementation seems easier to hack on?\n\nIf you're looking for a quick and easy to setup tool for feature analysis, this might be the one for you.\n\n## Key Features\n\nBoth the offline and online dashboards include:\n\n- Token-level activation highlighting\n- Hover tooltips showing token details\n- Responsive design\n- Save HTML reports\n\n### 1. Offline Feature Exploration\n\n- Analyze pre-computed feature activations\n- Visualize max activation examples for specific features\n- Expandable text views\n- Generate interactive HTML reports\n\nYou can either store the max activation examples in a database file, or in a python dictionary.\n\n#### A. Using a python dictionary\n\n```py\nfrom tiny_dashboard.feature_centric_dashboards import OfflineFeatureCentricDashboard\n\n# Create dashboard with pre-computed activations\nmax_activation_examples: dict[int, list[tuple[float, list[str], list[float]]]] = ...\n# max_activation_examples is a dictionary where the keys are feature indices and the values are lists of tuples. Each tuple contains a float (max activation value), a list of strings (the text of the example), and a list of floats (the activation values for each token in the example).\n\ndashboard = OfflineFeatureCentricDashboard(max_activation_examples, tokenizer)\ndashboard.display()\n\n# Export to HTML for sharing\nfeature_to_export = 0\ndashboard.export_to_html(\"feature_analysis.html\", feature_to_export)\n```\n\n#### B. Using a database file\n\nFor larger datasets, you can store your max activation examples in a `sqlite3` database. This allows you to avoid loading all the examples into memory.\nThe database should contain a table with:\n\n- A primary key column of type INTEGER\n- A column storing lists of examples as a JSON string, where each example is a tuple containing:\n  - max_activation_value (`float`): The highest activation value\n  - tokens (`list[str]`): The sequence of tokens\n  - activation_values (`list[float]`): The activation value for each token\n\n```py\ndashboard = OfflineFeatureCentricDashboard.from_db(\"path/to/db.db\", tokenizer, column_name=\"column_name_of_examples\")\ndashboard.display()\n```\n\nCheck [demo.ipynb](demo.ipynb) for an example on how to build such a database from a python dictionary.\n\n### 2. Online Feature Exploration\n\nThe online dashboard allows you to analyze the activations of a model in real-time. This is useful for quickly exploring the activations of a model on your custom prompts.\n\nThe online dashboard supports `chat_template` formatting: just include `\u003ceot\u003e` in your input text to separate your chat turns. E.g:\n\n```\nWhat is the capital of France?\u003ceot\u003eThe capital of France is Paris.\u003ceot\u003eGood bing\n```\n\nwill be interpreted as:\n\n```json\n[\n    {\"role\": \"user\", \"content\": \"What is the capital of France?\"},\n    {\"role\": \"assistant\", \"content\": \"The capital of France is Paris.\"},\n    {\"role\": \"user\", \"content\": \"Good bing\"}\n]\n```\n\nand formated using the tokenizer's chat template.\n\nTwo approaches to build your real-time feature analysis dashboard:\n\n#### A. Class-based Method\n\nCreate a class that implements the `AbstractOnlineFeatureCentricDashboard` class and implements the `get_feature_activation` function. This function should take a string and a tuple of feature indices and return a tensor of activation values of shape (seq_len, num_features) containing the activations of the specified features for the input text.\n\n```py\nfrom tiny_dashboard.feature_centric_dashboards import AbstractOnlineFeatureCentricDashboard\nclass DummyOnlineFeatureCentricDashboard(AbstractOnlineFeatureCentricDashboard):\n    def get_feature_activation(self, text: str, feature_indices: tuple[int, ...]) -\u003e th.Tensor:\n        # Custom activation computation logic\n        tok_len = len(self.tokenizer.encode(text))\n        activations = th.randn((tok_len, len(feature_indices))).exp()\n        return activations\n    \n    # Optional: override generate_model_response to change the model's response generation\n\nonline_dashboards = DummyOnlineFeatureCentricDashboard(tokenizer)\nonline_dashboards.display()\n```\n\n#### B. Function-based Method\n\nIf you hate classes for some reason, you can also use the function-based method:\n\n```py\nfrom tiny_dashboard.feature_centric_dashboards import OnlineFeatureCentricDashboard\ndef get_feature_activation(text, feature_indices):\n    return th.randn((len(tokenizer.encode(text)), len(feature_indices))).exp()\n\nonline_dashboards = OnlineFeatureCentricDashboard(\n    get_feature_activation, \n    tokenizer,\n    generate_model_response = None,  # Optional: override the model's response generation function\n    model = None,  # Optional: pass in a model to use the model's response generation function\n    call_with_self = False,  # Whether to call the functions with self as the first argument, defaults to Falses\n)\nonline_dashboards.display()\n```\n\n### Specialized Implementations\n\nThe package includes several specialized dashboard implementations in `dashboard_implementations.py`:\n\n#### CrosscoderOnlineFeatureDashboard\n\nFor analyzing features using a crosscoder model that combines base and instruct model activations:\n\n```python\nfrom tiny_dashboard.dashboard_implementations import CrosscoderOnlineFeatureDashboard\n\nbase_model, instruct_model, crosscoder = ...\ncollect_layer = 12\n\ndashboard = CrosscoderOnlineFeatureDashboard(\n    base_model=base_model,\n    instruct_model=instruct_model,\n    crosscoder=crosscoder,\n    collect_layer=collect_layer,\n    crosscoder_device=\"cuda\"  # optional, use it if the crosscoder is on a different device than the base and instruct models\n)\ndashboard.display()\n```\n\nAdditional specialized implementations can be found in the `dashboard_implementations.py` file. Feel free to contribute new implementations!\n\n## Repository Structure\n\nThe repository is organized as follows:\n\n- `demo.ipynb`: A Jupyter notebook containing minimal examples demonstrating how to use both offline and online dashboards\n- `src/`: Main package directory\n  - `feature_centric_dashboards.py`: Core implementation of the dashboard classes (OfflineFeatureCentricDashboard, OnlineFeatureCentricDashboard, and AbstractOnlineFeatureCentricDashboard)\n  - `dashboard_implementations.py`: Collection of specialized dashboard implementations (e.g., CrosscoderOnlineFeatureDashboard)\n  - `visualization_utils.py`: Utility functions for visualizing activations, without the need to use the dashboard classes\n  - `html_utils.py`: Utility functions for generating HTML elements using templates\n  - `utils.py`: General utility functions for text processing and HTML sanitization\n  - `templates/`: HTML, CSS, and JavaScript templates\n    - HTML templates for different components (base layout, feature sections, examples, etc.)\n    - `styles.css`: CSS styling for the dashboard\n    - `listeners.js`: JavaScript for interactive features (tooltips, expandable text)\n\n## Contributing\n\nContributions are welcome! Please feel free to improve the minimal design and add some usage examples.\n\n## Citation\n\nIf you find Tiny Activation Dashboard useful in your research or project, feel free to cite it as:\n\n```bibtex\n@misc{dumas2024tinyactivationdashboard,\n    title = {Tiny Activation Dashboard},\n    author = {Clément Dumas},\n    year = {2024},\n    howpublished = {\\url{https://github.com/Butanium/tiny-activation-dashboard}},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbutanium%2Ftiny-activation-dashboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbutanium%2Ftiny-activation-dashboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbutanium%2Ftiny-activation-dashboard/lists"}