{"id":30071405,"url":"https://github.com/graph-com/knowledge_unlearning","last_synced_at":"2025-08-08T12:42:43.323Z","repository":{"id":297506221,"uuid":"997018461","full_name":"Graph-COM/Knowledge_Unlearning","owner":"Graph-COM","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-05T20:26:57.000Z","size":1512,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-05T21:28:30.829Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/Graph-COM.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}},"created_at":"2025-06-05T20:25:57.000Z","updated_at":"2025-06-05T20:26:58.000Z","dependencies_parsed_at":"2025-06-05T21:38:49.422Z","dependency_job_id":null,"html_url":"https://github.com/Graph-COM/Knowledge_Unlearning","commit_stats":null,"previous_names":["graph-com/knowledge_unlearning"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Graph-COM/Knowledge_Unlearning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graph-COM%2FKnowledge_Unlearning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graph-COM%2FKnowledge_Unlearning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graph-COM%2FKnowledge_Unlearning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graph-COM%2FKnowledge_Unlearning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Graph-COM","download_url":"https://codeload.github.com/Graph-COM/Knowledge_Unlearning/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graph-COM%2FKnowledge_Unlearning/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269423874,"owners_count":24414615,"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-08-08T02:00:09.200Z","response_time":72,"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-08-08T12:42:40.612Z","updated_at":"2025-08-08T12:42:43.292Z","avatar_url":"https://github.com/Graph-COM.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \"Do LLMs Really Forget? Evaluating Unlearning with Knowledge Correlation and Confidence Awareness\" Project\n\n## Overview\nThis project focuses on our proposed knowledge unlearning framework for LLMs. This codebase provides the official implementation of our framework introduced in the paper.\n\n## Environment Setup\n\n### Method 1: Using conda\n``` sh\nconda env create -f environment.yml\nconda activate knowledge_unlearning\n```\n\n### Method 2: Using pip\n``` sh\nconda create -n knowledge_unlearning python=3.10\nconda activate knowledge_unlearning\npip install -r requirements.txt\n```\n## Project Structure\n```\nknowledge_unlearning/\n│── src/\n│   ├── data/\n│   │   ├── knowledge_graph.py  # Handles knowledge graph loading\n│   │   ├── text_conversion.py  # Converts KGs to text-based samples            \n│   │   ├── yago3-10/ # Select yago3-10 as the knowledge graph\n│   ├── models/\n│   │   ├── model_loader.py  # Load Model, Tokenizer, and Model Config\n│   ├── evaluation/\n│   │   ├── evaluator.py  # Query performance of the target LLM and construct subgraph\n│   │   ├── llm_evaluator.py  # Evaluate subgraph and target unlearning triples with powerful LLMs\n│   ├── main.py  # Main entry point for the project\n│   ├── utils/\n│   │   ├── utils.py\n│   ├── unlearning/\n│   │   ├── unlearn.py\n│   │   ├── methods/\n│   │   │   ├── gradient_ascent.py\n│   │   │   ├── random_label.py\n│   │   │   ├── negative_preference_optimization.py\n│   │   │   ├── ascent_plus_descent.py\n│   │   │   ├── scrub.py\n│   ├── config/\n│   │   ├── config.yml\n│   │   ├── config_judge.yml\n│   │   ├── config_subgraph.yml\n│   │   ├── config_threshold.yml\n│   │   ├── config_unlearn.yml\n│   │   ├── config_utility.yml\n│   ├── README.md\n```\n\n## Usage\n\n### Unlearn: Load Knowledge Graphs, Unlearn Target Triples over the Target LLM\n```sh\nnohup deepspeed --include localhost:1,2 --master_port=33333 src/main_finetune.py --config config/config_unlearn.yml --unlearn \u003e output.log 2\u003e\u00261 \u0026\n```\n\n\n#### Important Parameters in `config_unlearn.yml`\n\n- `huggingface`  \n  - `hf_token`: The token associated with your Hugging Face account\n\n- `model`  \n  - `name`: Name of the unlearning model\n\n- `unlearn`  \n  - `use_QA_unlearning`: Set to `true` to use QA unlearning, `false` to use Sentence unlearning  \n  - `peft_config`: `\"LoRA\"` indicates using LoRA-based unlearning; any other value indicates full-parameter unlearning  \n  - `method`: Unlearning method to be applied\n\n- `output`  \n  - `unlearn_model_dir`: Path to save the checkpoint\n\n\n\n### Construct Supporting Subgraph:\n```sh\nnohup python src/main_finetune.py --config config/config_subgraph.yml --subgraph \u003e output.log 2\u003e\u00261 \u0026\n```\n\n#### Important Parameters in `config_subgraph.yml`\n\n- `huggingface`  \n  - `hf_token`: The token associated with your Hugging Face account\n\n- `model`  \n  - `name`: Name of the unlearning model  \n  - `merge_lora`: Set to `true` if the unlearned model was unlearned using LoRA; set to `false` if it was unlearned using full-parameter unlearning  \n  - `save_merged_model_path`: If the unlearned model is trained using LoRA unlearning, this specifies the path to save the merged model after combining the LoRA adapter with the original model  \n  - `checkpoint_path`: If the unlearned model is trained using LoRA unlearning, this is the path where the LoRA adapter is saved. If the model is trained with full-parameter unlearning, this is the path where the model parameters are saved  \n\n- `subgraph`  \n  - `k_hop`: Number of hops for the Supporting Subgraph  \n  - `unlearn_method`: Unlearning method to be applied  \n  - `eval_unlearn_triples`: Should be set to `true` when constructing the Supporting Subgraph  \n  - `score_unlearn_triples`: Should be set to `false` when constructing the Supporting Subgraph  \n\n- `output`  \n  - `subgraph_dir`: Directory to save the extracted subgraph\n\n\n\n### Evaluate Unlearn Triples:\n```sh\nnohup python src/main_finetune.py --config config/config_subgraph.yml --subgraph \u003e output.log 2\u003e\u00261 \u0026\n```\n\nSimilar to **Construct Supporting Subgraph**, but with the following settings:\n\n- `eval_unlearn_triples`: set to `false`\n- `score_unlearn_triples`: set to `true`\n\n\n\n### Evaluate Utility Triples:\n```sh\nnohup python src/main_finetune.py --config config/config_utility.yml --utility \u003e output.log 2\u003e\u00261 \u0026\n```\n\n#### Important Parameters in `config_utility.yml`\n\n**utility**  \n- `run_normal`: Specify whether to perform normal utility evaluation.\n\n**output**  \n- `score_dir`: Directory where the results will be saved.\n\n\n### Evaluation with Powerful LLMs:\n```sh\nnohup python src/main_finetune.py --config config/config_judge.yml --judge \u003e output.log 2\u003e\u00261 \u0026\n```\n\n#### Important Parameters in `config_judger.yml`\n\n**input**  \n- `judge_superficial`: Specify whether to score only the unlearn triples.  \n- `judge_superficial_path`: Path to the results saved after Evaluate Unlearn Triples.  \n- `judge_subgraph_path`: Path to the results saved after Construct Supporting Subgraph.  \n\n**output**  \n- `output_superficial_path`: Path to save the scoring results for unlearn triples.  \n- `evaluation_output_file`: Path to save the scoring results for supporting subgraphs.\n\n\n## Supported Models\n- Qwen/Qwen2.5-7B-Instruct\n- meta-llama/Llama-3.1-8B-Instruct\n\n## Supported Unlearning Methods\n- gradient_ascent\n- random_label\n- npo\n- ascent_plus_descent\n- scrub\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraph-com%2Fknowledge_unlearning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraph-com%2Fknowledge_unlearning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraph-com%2Fknowledge_unlearning/lists"}