{"id":22434415,"url":"https://github.com/vvukimy/mdr","last_synced_at":"2026-03-02T11:01:30.787Z","repository":{"id":228572029,"uuid":"774359056","full_name":"vvukimy/MDR","owner":"vvukimy","description":"Code for NAACL 2024 \"MDR: Model-Specific Demonstration Retrieval at Inference Time for In-Context Learning\".","archived":false,"fork":false,"pushed_at":"2024-07-04T12:15:54.000Z","size":236,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-01T14:51:29.811Z","etag":null,"topics":["in-context-learning","large-language-models","retrieval-augmented-generation"],"latest_commit_sha":null,"homepage":"","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/vvukimy.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}},"created_at":"2024-03-19T12:13:52.000Z","updated_at":"2025-02-01T23:08:15.000Z","dependencies_parsed_at":"2024-11-09T19:32:14.444Z","dependency_job_id":null,"html_url":"https://github.com/vvukimy/MDR","commit_stats":null,"previous_names":["kiming-ng/mdr","vvukimy/mdr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vvukimy/MDR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvukimy%2FMDR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvukimy%2FMDR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvukimy%2FMDR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvukimy%2FMDR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vvukimy","download_url":"https://codeload.github.com/vvukimy/MDR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvukimy%2FMDR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29999216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T09:59:02.300Z","status":"ssl_error","status_checked_at":"2026-03-02T09:59:02.001Z","response_time":60,"last_error":"SSL_read: 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":["in-context-learning","large-language-models","retrieval-augmented-generation"],"created_at":"2024-12-05T23:07:48.636Z","updated_at":"2026-03-02T11:01:30.753Z","avatar_url":"https://github.com/vvukimy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MDR\nCode for NAACL 2024 paper: [MDR: Model-Specific Demonstration Retrieval at Inference Time for In-Context Learning](https://aclanthology.org/2024.naacl-long.235/).\n\n## Environment Setup\n```bash\ncd MDR\nbash install.sh \n```\n\n## Preparation\nFollow the instructions in [UPRISE](https://github.com/microsoft/LMOps/tree/main/uprise#1-download-retriever-and-prompt-pool) to download pre-trained retriever and pre-constructed demonstration pool. \n\nAfter downloading, encode the demonstration pool with the demonstration encoder:\n```bash\nbash ./scripts/gen_demonstration_embeds.sh\n```\n\n## Quick Start\nDownload [demonstration_pool_GPTNeo.json](https://drive.google.com/file/d/1m4ls7Unl36-NaGCLyKPAUtqeMAZJcb6J/view?usp=drive_link) to `./demonstration_pools`. Then run the provided shell to evaluate MDR on different tasks with GPTNeo-2.7B and get to know the demonstration retrieval process:\n\n```bash\nbash ./scripts/run_GPTNeo_2.7B.sh\n```\n\nYou can change the variable `DEMONSTRATION_POOL` to `path_to_demonstration_pool` (downloaded from UPRISE) to see how MDR calculate eigenvalue and loss for each sample in test dataset given specific inference model.\n\n## Evaluation MDR on any tasks and models\nCustomize your scripts to support different tasks and models based on the parameters:\n- `LLM`: you can specify the LLM name here (in huggingface format);\n- `DEMONSTRATION_POOL`: since the calculation of eigenvalue and loss has a one-to-one correspondence with the model, you should create different demonstration pool files for different models (just copy the downloaded demonstration pool file and rename it);\n- `TASKS`: MDR support 20+ datasets, you can specify the task name to evaluate according to the task definition in `./DPR/dpr/utils/tasks.py`;\n  \n\n## Acknowledgement\nThis repository is built using the [UPRISE](https://github.com/microsoft/LMOps/tree/main/uprise) codebase.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvukimy%2Fmdr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvvukimy%2Fmdr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvukimy%2Fmdr/lists"}