{"id":23980319,"url":"https://github.com/ejnnr/cupbearer","last_synced_at":"2025-09-13T11:31:29.658Z","repository":{"id":185137739,"uuid":"617164882","full_name":"ejnnr/cupbearer","owner":"ejnnr","description":"A library for mechanistic anomaly detection","archived":false,"fork":false,"pushed_at":"2025-01-09T11:51:09.000Z","size":5912,"stargazers_count":22,"open_issues_count":8,"forks_count":11,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-18T05:26:51.850Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ejnnr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-03-21T20:29:57.000Z","updated_at":"2025-06-19T10:29:11.000Z","dependencies_parsed_at":"2024-01-12T18:42:05.454Z","dependency_job_id":"29212df7-5a83-4ad5-8693-f5a9a22fe725","html_url":"https://github.com/ejnnr/cupbearer","commit_stats":null,"previous_names":["ejnnr/abstractions","ejnnr/cupbearer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ejnnr/cupbearer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejnnr%2Fcupbearer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejnnr%2Fcupbearer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejnnr%2Fcupbearer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejnnr%2Fcupbearer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ejnnr","download_url":"https://codeload.github.com/ejnnr/cupbearer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejnnr%2Fcupbearer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274956110,"owners_count":25380670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-01-07T10:01:22.126Z","updated_at":"2025-09-13T11:31:29.650Z","avatar_url":"https://github.com/ejnnr.png","language":"Python","funding_links":[],"categories":["Mechanistic interpretability libraries"],"sub_categories":[],"readme":"# `cupbearer` 🍷\n`cupbearer` is a Python library for\n[mechanistic anomaly detection](https://www.alignmentforum.org/posts/vwt3wKXWaCvqZyF74/mechanistic-anomaly-detection-and-elk).\nIts main purpose is to make it easy to implement either a new mechanistic anomaly\ndetection *task*, or a new detection *method*, and evaluate it against a suite of existing\ntasks or methods. To that end, the library provides:\n- A clearly defined interface for tasks and detectors to ensure compatibility\n- Scripts and other helpers for training and evaluating detectors that satisfy this interface\n  (to reduce the amount of boilerplate code you need to write)\n- Implementations of several tasks and detectors as baselines (currently not that many)\n\nContributions of new tasks or detectors are very welcome!\nSee the [developer guide](docs/getting_started.md) to get started.\n\n## Installation\nThe easy way: inside a virtual environment with Python \u003e= 3.10, run\n```bash\npip install git+https://github.com/ejnnr/cupbearer.git\n```\n(You could also `pip install cupbearer`, but note that the library is under heavy\ndevelopment and the PyPi version will often be outdated.)\n\nAlternatively, if you're going to do development work on the library itself,\nsee [the developer guide](docs/getting_started.md).\n\n### Notes on Pytorch\nDepending on what platform you're on, you may need to install Pytorch separately *before*\ninstalling `cupbearer`, in particular if you want to control CUDA version etc.\n\n## Running experiments\nWe provide scripts in `cupbearer.scripts` for more easily running experiments.\nSee [the demo notebook](notebooks/simple_demo.ipynb) for a quick example of how to use them---this is likely\nalso the best way to get an overview of how the components of `cupbearer` fit together.\n\nThese \"scripts\" are Python functions and designed to be used from within Python,\ne.g. in a Jupyter notebook or via [submitit](https://github.com/facebookincubator/submitit/tree/main)\nif on Slurm. But of course you could also write a simple Python wrapper and then use\nthem from the CLI. The scripts are designed to be pretty general,\nwhich sometimes comes at the cost of being a bit verbose---we recommend writing helper\nfunctions for your specific use case on top of the general script interface.\nOf course you can also use the components of `cupbearer` directly without going through\nany of the scripts.\n\n## Whence the name?\nJust like a cupbearer tastes wine to avoid poisoning the king, mechanistic anomaly\ndetection methods taste new inputs to check whether they're poisoned. (Or more generally,\nanomalous in terms of how they affect the king ... I mean, model. I admit the analogy\nis becoming a bit strained here.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejnnr%2Fcupbearer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fejnnr%2Fcupbearer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejnnr%2Fcupbearer/lists"}