{"id":19771991,"url":"https://github.com/danieldacosta/detoxifying-text-marco","last_synced_at":"2026-06-14T10:34:05.088Z","repository":{"id":204619651,"uuid":"701958302","full_name":"DanielDaCosta/detoxifying-text-marco","owner":"DanielDaCosta","description":"Reproduction study of the paper \"Detoxifying Text with MaRCo: Controllable Revision with Experts and Anti-Experts\"","archived":false,"fork":false,"pushed_at":"2024-07-20T18:13:25.000Z","size":18426,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T11:30:43.671Z","etag":null,"topics":["bart","detoxify","masking","nlp","toxicity"],"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/DanielDaCosta.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-10-08T04:28:33.000Z","updated_at":"2024-09-10T21:27:40.000Z","dependencies_parsed_at":"2024-07-20T19:29:08.918Z","dependency_job_id":"8deabb5a-107f-4192-917f-b0b73d2d9898","html_url":"https://github.com/DanielDaCosta/detoxifying-text-marco","commit_stats":null,"previous_names":["danieldacosta/detoxifying-text-marco"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DanielDaCosta/detoxifying-text-marco","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielDaCosta%2Fdetoxifying-text-marco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielDaCosta%2Fdetoxifying-text-marco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielDaCosta%2Fdetoxifying-text-marco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielDaCosta%2Fdetoxifying-text-marco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DanielDaCosta","download_url":"https://codeload.github.com/DanielDaCosta/detoxifying-text-marco/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielDaCosta%2Fdetoxifying-text-marco/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34318523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"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":["bart","detoxify","masking","nlp","toxicity"],"created_at":"2024-11-12T05:05:02.996Z","updated_at":"2026-06-14T10:34:05.072Z","avatar_url":"https://github.com/DanielDaCosta.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reproduction Study: MaRCo Detoxification\nThis is the repository for the 2023 ACL Paper [\"Detoxifying Text with MaRCo: Controllable Revision with Experts and Anti-Experts\"](https://arxiv.org/abs/2212.10543)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://pbs.twimg.com/media/FkeZuLBUUAA6abX?format=jpg\u0026name=4096x4096\" alt=\"drawing\" width=\"75%\"/\u003e\n\u003c/p\u003e\n\nAuthor's original [Github Repo](https://github.com/shallinan1/MarcoDetoxification) \n\n## Dependencies\n\n### \u003cins\u003eSetting up the Environment\u003c/ins\u003e\nTo set up the environment to run the code, make sure to have conda installed, then run\n\n    conda env create -f environment.yml\n\nThen, activate the environment\n\n    conda activate rewrite\n\n**Important!**: The environment is setup to run with a CUDA version compatible with RTX6000 GPUs. You may need to update the environment based on your own GPUs.\n\n### \u003cins\u003eCompute Requirements\u003c/ins\u003e\n\nWe recommend using a single RTX6000 GPU (this is what we used for our experiments) or another NVIDIA GPU with \u003e24GB VRAM to enable large-scale rewriting (large batch size). Our method can also run on smaller models \u003c24GB VRAM, but you should set the batch size to be lower.\n\n## Datasets and Preprocess\nSee `datasets/README.md` for access to the datasets and a description.\n\n## Training\nSee `training/README.md` for code and commands.\n\nThe pre-trained models used were downloaded from hugging face:\n- BART-Base: https://huggingface.co/facebook/bart-base\n- BART-Small: https://huggingface.co/lucadiliello/bart-small\n- Mistral-7B: [Together AI pre-trainned model](https://docs.together.ai/docs/inference-models)\n\nAll batch scripts utilized for jobs on CARC can be located in the `CARC/` folder, alongside the respective outputs and training logs for each job.\n\n\n## Evaluation\nSee `evaluation/README.md` for code and commands.\n\n\u003c!-- ### \u003cins\u003eDetoxification with MaRCo\u003c/ins\u003e\n\nSee `rewrite/README.md` for details on how to run the detoxification pipeline, --\u003e\n\n\n\n## Citing this Work\nIf you use/reference this work, please cite us with:\n\n    @inproceedings{hallinan-etal-2023-detoxifying,\n        title = \"Detoxifying Text with {M}a{RC}o: Controllable Revision with Experts and Anti-Experts\",\n        author = \"Hallinan, Skyler  and\n          Liu, Alisa  and\n          Choi, Yejin  and\n          Sap, Maarten\",\n        booktitle = \"Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers)\",\n        month = jul,\n        year = \"2023\",\n        address = \"Toronto, Canada\",\n        publisher = \"Association for Computational Linguistics\",\n        url = \"https://aclanthology.org/2023.acl-short.21\",\n        doi = \"10.18653/v1/2023.acl-short.21\",\n        pages = \"228--242\",\n        abstract = \"Text detoxification has the potential to mitigate the harms of toxicity by rephrasing text to remove offensive meaning, but subtle toxicity remains challenging to tackle. We introduce MaRCo, a detoxification algorithm that combines controllable generation and text rewriting methods using a Product of Experts with autoencoder language models (LMs). MaRCo uses likelihoods under a non-toxic LM (expert) and a toxic LM (anti-expert) to find candidate words to mask and potentially replace. We evaluate our method on several subtle toxicity and microaggressions datasets, and show that it not only outperforms baselines on automatic metrics, but MaRCo{'}s rewrites are preferred 2.1 times more in human evaluation. Its applicability to instances of subtle toxicity is especially promising, demonstrating a path forward for addressing increasingly elusive online hate.\",\n    }\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieldacosta%2Fdetoxifying-text-marco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanieldacosta%2Fdetoxifying-text-marco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieldacosta%2Fdetoxifying-text-marco/lists"}