{"id":26218631,"url":"https://github.com/edisonleeeee/in-context-rag","last_synced_at":"2026-04-29T05:34:50.637Z","repository":{"id":274599425,"uuid":"923363454","full_name":"EdisonLeeeee/In-Context-RAG","owner":"EdisonLeeeee","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-21T01:44:09.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T14:15:15.840Z","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/EdisonLeeeee.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":"2025-01-28T05:14:30.000Z","updated_at":"2025-05-21T01:44:13.000Z","dependencies_parsed_at":"2025-01-28T09:39:38.392Z","dependency_job_id":null,"html_url":"https://github.com/EdisonLeeeee/In-Context-RAG","commit_stats":null,"previous_names":["edisonleeeee/in-context-rag"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EdisonLeeeee/In-Context-RAG","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdisonLeeeee%2FIn-Context-RAG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdisonLeeeee%2FIn-Context-RAG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdisonLeeeee%2FIn-Context-RAG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdisonLeeeee%2FIn-Context-RAG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EdisonLeeeee","download_url":"https://codeload.github.com/EdisonLeeeee/In-Context-RAG/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdisonLeeeee%2FIn-Context-RAG/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32412890,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T05:20:56.964Z","status":"ssl_error","status_checked_at":"2026-04-29T05:19:54.749Z","response_time":110,"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":[],"created_at":"2025-03-12T13:18:47.698Z","updated_at":"2026-04-29T05:34:50.620Z","avatar_url":"https://github.com/EdisonLeeeee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# In-context RAG\n\n## Environment Setup\n+ Step 0: Create a new Conda virtual environment\n```bash\nconda create -n labelrag python==3.12 -c conda-forge -y\nconda activate labelrag\n```\n+ Step 1: Install PyTorch 2.4 or [other versions](https://pytorch.org/)\n```bash\npip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0\n```\n+ Step 2: Install dependencies\n```bash\npip install transformers peft numpy pandas tqdm nest_asyncio huggingface_hub sentence_transformers\npip install deepspeed trl tensorboard loguru triton bitsandbytes tiktoken modelscope ogb\npip install flash-attn\n```\n+ Step 3: Install the corresponding version of `vllm` (compatible with PyTorch 2.4)\n```bash\npip install vllm==0.6.3.post1\n```\n+ Step 4: Install [swift](https://github.com/modelscope/ms-swift), version 3.x is required\n```bash\npip install 'ms-swift[llm]'\n```\n+ Step 5: Install [PyG](https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html)\n```bash\npip install torch_geometric\n```\n+ Step 6: Install [DGL](https://www.dgl.ai/pages/start.html) (only for loading graph data)\n+ Step 7 (optional): Install FAISS\n```bash\nconda install -c pytorch -c nvidia faiss-gpu=1.8.0 -y\n# pip install faiss-gpu\n```\n+ Step 8 (optional): Install `git-lfs` for downloading large models\n```bash\napt-get install git-lfs\n```\n\n## Download Datasets\n+ Download CSTAG-related datasets. The `ogbn-arxiv` dataset will be downloaded automatically in the code.\n```bash\nhuggingface-cli download --repo-type dataset --resume-download Sherirto/CSTAG --local-dir CSTAG --local-dir-use-symlinks False\n```\nIf the download fails in regions with restricted access, use a mirror source:\n```bash\nHF_ENDPOINT=https://hf-mirror.com huggingface-cli download --repo-type dataset --resume-download Sherirto/CSTAG --local-dir CSTAG --local-dir-use-symlinks False\n```\n\n+ Download DTGB from [DTGN](https://github.com/zjs123/DTGB)\n\n## Download Models from ModelScope\n```bash\ngit lfs clone https://www.modelscope.cn/LLM-Research/Meta-Llama-3.1-8B-Instruct.git\ngit lfs clone https://www.modelscope.cn/qwen/Qwen2.5-7B-Instruct.git\ngit lfs clone https://www.modelscope.cn/LLM-Research/gemma-2-9b-it.git\ngit lfs clone https://www.modelscope.cn/LLM-Research/Mistral-7B-Instruct-v0.3.git\ngit lfs clone https://www.modelscope.cn/LLM-Research/Phi-3.5-mini-instruct.git\nhuggingface-cli download --resume-download sentence-transformers/all-mpnet-base-v2 --local-dir ./all-mpnet-base-v2\n```\n**Note**: After cloning with `git lfs`, the `.git` folder in the model directory may take up significant space. Make sure to remove it if necessary:\n```bash\ncd Meta-Llama-3.1-8B-Instruct \u0026\u0026 rm -rf .git\n```\n\n## Run the Code\n+ Preprocess datasets and construct prompts:\n```python\npython generate_prompt_node.py\npython generate_prompt_edge.py\n```\n+ Configure the `gpu_ids` in the shell script, then run all models in one command (multi-GPU inference with native PyTorch):\n```bash\nbash scripts/run_node.sh \nbash scripts/run_edge.sh \n```\n\nFor more parameter details, refer to the Swift documentation: [Command Line Parameters](https://swift.readthedocs.io/en/latest/Instruction/Command-line-parameters.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedisonleeeee%2Fin-context-rag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedisonleeeee%2Fin-context-rag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedisonleeeee%2Fin-context-rag/lists"}