[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-xlang-ai--UnifiedSKG":3,"tool-xlang-ai--UnifiedSKG":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":79,"owner_twitter":80,"owner_website":81,"owner_url":82,"languages":83,"stars":92,"forks":93,"last_commit_at":94,"license":95,"difficulty_score":96,"env_os":97,"env_gpu":98,"env_ram":99,"env_deps":100,"category_tags":114,"github_topics":115,"view_count":23,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":129,"updated_at":130,"faqs":131,"releases":162},2781,"xlang-ai\u002FUnifiedSKG","UnifiedSKG","[EMNLP 2022] Unifying and multi-tasking structured knowledge grounding with language models","UnifiedSKG 是一个旨在统一并多任务处理“结构化知识接地”（SKG）的开源框架，曾荣获 EMNLP 2022 口头报告奖。它的核心目标是将原本分散在不同领域、格式各异的 21 类 SKG 任务（如数据库语义解析、知识库问答等），全部转化为统一的“文本到文本”格式。这一设计解决了以往因输入输出异构而导致的研究割裂问题，让研究人员能够在一个框架下系统性地探索和比较不同任务。\n\n该工具特别适合自然语言处理领域的研究人员和开发者使用。借助 UnifiedSKG，用户可以直接利用 T5 等大型语言模型，在几乎全部 21 个任务上取得业界领先的性能。其独特的技术亮点在于强大的多任务学习能力，通过简单的前缀微调（prefix-tuning）即可显著提升整体表现；同时，它也是一个极具挑战性的零样本和少样本学习测试平台，能够有效评估模型在复杂结构化知识场景下的泛化能力。此外，框架具有良好的扩展性，欢迎社区贡献新的数据集、模型或评估指标，共同推动结构化知识理解技术的发展。","# UnifiedSKG:books:: Unifying and Multi-Tasking Structured Knowledge Grounding with Text-to-Text Language Models\n\n\u003Cp align=\"left\">\n    \u003Ca href=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPRs-Welcome-red\">\n        \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPRs-Welcome-red\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flast-commit\u002FHKUNLP\u002FUnifiedSKG?color=green\">\n        \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flast-commit\u002FHKUNLP\u002FUnifiedSKG?color=green\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1f9yTXC3GpSyRJOjzsKceG_bhk-Cw71Ga#scrollTo=r_3-DN0SvC97\">\n        \u003Cimg alt=\"Open In Colab\" src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\">\n    \u003C\u002Fa>\n    \u003Cbr\u002F>\n\u003C\u002Fp>\n\nCode for EMNLP 2022 (oral) paper [UnifiedSKG: Unifying and Multi-Tasking Structured Knowledge Grounding with Text-to-Text Language Models](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.05966). Please refer to our [project page](https:\u002F\u002Funifiedskg.com\u002F) for up-to-date related resources (e.g., papers, code, tools, tutorials) for Structured Knowledge Grounding. Load our checkpoints from [HuggingFace Model Hub](https:\u002F\u002Fhuggingface.co\u002Fhkunlp).\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_7a774ae3558e.png\" align=\"middle\" width=\"100%\">\n\n**S**tructured **k**nowledge **g**rounding (**SKG**) leverages structured knowledge to complete user requests, such as semantic parsing over databases and question answering over knowledge bases. Since the inputs and outputs of SKG tasks are heterogeneous, they were historically studied in separate by different communities,  which limits systematic and compatible research on SKG. In this paper, we overcome this limitation by proposing the **UnifiedSKG framework**, which unifies **21 SKG tasks** into the text-to-text format, aiming to promote systematic SKG research, instead of being exclusive to a single task, domain, or dataset. We show that large language models like T5, with simple modification when necessary, achieve **state-of-the-art performance on nearly all 21 tasks**. UnifiedSKG facilitates **multi-task learning**. We show that multi-task prefix-tuning benefits most tasks, largely improving the overall performance. UnifiedSKG is a challenging testbed for **zero-shot and few-shot learning**, which T0, GPT-3, and Codex struggle in. UnifiedSKG also enables a series of controlled experiments on **structured knowledge encoding** variants across SKG tasks. We find that T5’s sensitivity to structured knowledge encoding variations varies across tasks. \n\n**UnifiedSKG** is easily extensible. Your **pull requests** to add datasets, settings, metrics, models, and new features to UnifiedSKG are highly welcome! \n\n## Updates\n- **2022-03-12**: Check out the seq2seq data we processed for you [here](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1GXigUv3MU-Sh4XiY6Wz3xVeNT_s0SuON) by UnifiedSKG if you want to make your own attempts instead of using the huggingface loaders in our framework. \n- **2022-01-12**: We released our [code](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG), [colab demo](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1f9yTXC3GpSyRJOjzsKceG_bhk-Cw71Ga#scrollTo=r_3-DN0SvC97), [weights](https:\u002F\u002Fhuggingface.co\u002Fhkunlp) and [project page](https:\u002F\u002Funifiedskg.com). Check it out!\n\n## Content\n\n- [UnifiedSKG: Unifying and Multi-Tasking **S**tructured **K**nowledge **G**rounding with Text-to-Text Language Models](#unifiedskgbooks-unifying-and-multi-tasking-structured-knowledge-grounding-with-text-to-text-language-models)\n  * [Cloning this Repo](#cloning-this-repo)\n  * [Dependencies](#dependencies)\n  * [Usage](#usage)\n    + [Environment setup](#environment-setup)\n    + [Wandb setup](#wandb-setup)\n    + [Training](#training)\n    + [Load weights](#load-weights)\n  * Introduction of each directory\n    + [configure](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fconfigure)\n    + [metrics](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmetrics)\n    + [models](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmodels)\n    + [seq2seq_construction](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fseq2seq_construction)\n    + [third_party](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fthird_party)\n    + [utils](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Futils)\n  * [Code structure overview of UnifiedSKG](#code-structure-overview-of-unifiedskg)\n  * [Add a new task into UnifiedSKG](#add-a-new-task-into-unifiedskg)\n  * [Misc](#misc)\n  * [Contributors](#contributors)\n\n\n\n\n## Cloning this repo\n\nIn order to include third-party dependencies in this repository, make sure to clone recursively, e.g.:\n\n```\ngit clone --recurse-submodules git@github.com:HKUNLP\u002FUnifiedSKG.git\n```\n\n## Dependencies\n\nTo establish the environment run this code in the shell (the third line is for CUDA11.1):\n\n``````\nconda env create -f py3.7pytorch1.8.yaml\nconda activate py3.7pytorch1.8new\npip install datasets==1.14.0\n# The following line to be replaced depending on your cuda version.\npip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Ftorch_stable.html\n``````\n\nThat will create the environment `py3.7pytorch1.8new` we used. \n\n\u003C!--\n### Sub-Modules\n\nSome third party libraries stored in sub-modules need installation\n\n#### ~~TaPEx~~（we adopted its table processor into our code to do some changes）\n\n~~For TaPEx, you can run~~\n\n```\ncd third_party\u002Ftable_pretraining\u002F\npip install --editable .\u002F\ncd ..\u002F..\n```\n\n\n#### TaBERT\n\nRun the following with the conda env activated and *after* installing the main dependencies for UniPSP:\n``````\npip install --editable=git+https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers.git@372a5c1ceec49b52c503707e9657bfaae7c236a0#egg=pytorch_pretrained_bert fairseq==0.8.0 torch-scatter==1.3.2 ujson msgpack redis zmq h5py\n``````\n\nThen, navigate to the TaBERT directory and install it:\n\n``````\ncd third_party\u002Ftabert\u002F\npip install --editable .\u002F\ncd ..\u002F..\n``````\n\nAnd if you add more modification to the env or more commands during you adding for unification, \nplease note in the block below of this README:\n\n``````\n*add*me*\n``````\nwe will compress them to create a docker environment in the end. \n\n-->\n\n## Usage\n\n### Environment setup\nActivate the environment by running\n``````shell\nconda activate py3.7pytorch1.8new\n``````\n\n### WandB setup\n\nSetup [WandB](https:\u002F\u002Fwandb.ai\u002F) for logging (registration needed):\n``````shell\nexport WANDB_API_KEY=YOUR_WANDB_API_KEY\nexport WANDB_PROJECT=YOUR_PROJECT_NAME\nexport WANDB_ENTITY=YOUR_TEAM_NAME\n``````\n\n### Training\n\nT5-base finetuning on WikiTQ (4 GPUs, 128 effective batch size)\n``````shell\npython -m torch.distributed.launch --nproc_per_node 4 --master_port 1234 train.py --seed 2 --cfg Salesforce\u002FT5_base_finetune_wikitq.cfg --run_name T5_base_finetune_wikitq --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 500 --metric_for_best_model avr --greater_is_better true --save_strategy steps --save_steps 500 --save_total_limit 1 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 400 --adafactor true --learning_rate 5e-5 --do_train --do_eval --do_predict --predict_with_generate --output_dir output\u002FT5_base_finetune_wikitq --overwrite_output_dir --per_device_train_batch_size 4 --per_device_eval_batch_size 16 --generation_num_beams 4 --generation_max_length 128 --input_max_length 1024 --ddp_find_unused_parameters true\n``````\nIf you want to resume training, remove the ``--overwrite_output_dir`` flag from the above command:\n``````shell\npython -m torch.distributed.launch --nproc_per_node 4 --master_port 1234 train.py --seed 2 --cfg Salesforce\u002FT5_base_finetune_wikitq.cfg --run_name T5_base_finetune_wikitq --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 500 --metric_for_best_model avr --greater_is_better true --save_strategy steps --save_steps 500 --save_total_limit 1 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 400 --adafactor true --learning_rate 5e-5 --do_train --do_eval --do_predict --predict_with_generate --output_dir output\u002FT5_base_finetune_wikitq --per_device_train_batch_size 4 --per_device_eval_batch_size 16 --generation_num_beams 4 --generation_max_length 128 --input_max_length 1024 --ddp_find_unused_parameters true\n``````\n\nT5-base prefix-tuning on WikiTQ (4 GPUs, 128 effective batch size)\n``````shell\npython -m torch.distributed.launch --nproc_per_node 4 --master_port 1234 train.py --seed 2 --cfg Salesforce\u002FT5_base_prefix_wikitq.cfg --run_name T5_base_prefix_wikitq --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 500 --metric_for_best_model avr --greater_is_better true --save_strategy steps --save_steps 500 --save_total_limit 1 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 400 --adafactor true --learning_rate 5e-5 --do_train --do_eval --do_predict --predict_with_generate --output_dir output\u002FT5_base_prefix_wikitq --overwrite_output_dir --per_device_train_batch_size 4 --per_device_eval_batch_size 16 --generation_num_beams 4 --generation_max_length 128 --input_max_length 1024 --ddp_find_unused_parameters true\n``````\n\nT5-3b finetuning on WikiTQ (8 GPUs, 128 effective batch size)\n``````shell\ndeepspeed train.py --deepspeed deepspeed\u002Fds_config_zero2.json --seed 2 --cfg Salesforce\u002FT5_3b_finetune_wikitq.cfg --run_name T5_3b_finetune_wikitq --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 500 --metric_for_best_model avr --greater_is_better true --save_strategy steps --save_steps 500 --save_total_limit 1 --load_best_model_at_end --gradient_accumulation_steps 16 --num_train_epochs 50 --adafactor false --learning_rate 5e-5 --do_train --do_eval --do_predict --predict_with_generate --output_dir output\u002FT5_3b_finetune_wikitq --overwrite_output_dir --per_device_train_batch_size 1 --per_device_eval_batch_size 1 --generation_num_beams 4 --generation_max_length 128 --input_max_length 1024 --ddp_find_unused_parameters true\n``````\n\n### Load weights\nSee \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1f9yTXC3GpSyRJOjzsKceG_bhk-Cw71Ga#scrollTo=r_3-DN0SvC97\">\n        \u003Cimg alt=\"Open In Colab\" src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\">\n    \u003C\u002Fa>\n \n\u003C!--\n## Introduction of each file\n\n### [configure](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fconfigure)\n\nCode for configuration of different tasks\u002Fsettings, more details see README in [.\u002Fconfigure](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fconfigure)\n\n### [metrics](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmetrics)\nCode for evaluating the prediction of our model, more details see README in [.\u002Fmetrics](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmetrics)\n\n### [models](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmodels)\nCode for models(for now, we have seq2seq models(T5 and BART) and prompt-tuning models(prefix-tuning)\n\n### [seq2seq_construction](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fseq2seq_construction)\nCode for evaluating the prediction of our model, more details see README in [.\u002Fseq2seq_construction](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fseq2seq_construction)\n\n### [third_party](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fthird_party)\nPackages from the third party for us to tmp store, and we will redirect them by git recursive deployment in the end. \n\n### [utils](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Futils)\nCode for some useful(or not) stuff, it contains:\n- **configure.py**: The \"args\" data-structure for **parsing and store the config files** in .\u002Fconfigure. (and we are trying to change it \ninto a more main-stream structure which also support read from the file and create nested config object.)\n- **dataset.py**: Wrap the seq2seq dataset to tokenize the \"seq_in\" and \"seq_out\", since the trainer only support tokenized tensors of \"seq_input\" and \"seq_output\" as input\n- **tool.py**: The tool to **get datasets, models and evaluators in a unified way**. \n- **trainer.py**: The **modified trainer version** of huggingface trainer class **for supporting meta-tuning**(we want get our training sampler under our control), \n**easier evaluation**(the metrics of huggingface's input format(numbers) is contradicted with ones of all official evaluations) and **further changes in this project**(for example, we want to feed more para in a model.forward function).\n- **training_arguments.py**: The **customized wrapped training_arguments**.\n\n### train.py\n- together with the config file, act as the start and main-control of the experiment.\n\n### Procedure\nThe working procedure of our work follows:\nraw data(s) -> + seq2seq data(s) (\"seq_in\" and \"seq_out\") -> tokenized -> seq2seq_trainer -> predictions -> eval(s)\n-->\n\n## Code structure overview of UnifiedSKG\n    .\n    ├── configure                              # Config files for experiments, tasks, and settings\n    │   ├── META_TUNING                        # Config files for tasks and settings\n    │   └── Salesforce                         # Config files for experiments (see Misc)\n    │\n    ├── metrics                                # Code for evaluation\n    │   └── ...                                # Please check the README of the .\u002Fseq2seq_construction.\n    ├── models                                 # Code for models\n    │   ├── adapter                            # Code for T5 and BART with adapters (based on HuggingFace Transformers)\n    │   ├── prompt                             # Code for T5 and BART with prefix-tuning (based on HuggingFace Transformers)\n    │   └── unified\n    │           ├── base.py                    # Code for the base model that enables an arbitrary model to be pushed to HuggingFace Model Hub (namely, PushToHubFriendlyModel)\n    │           ├── finetune.py                # Code for finetuning\n    │           ├── adaptertuning.py           # Code for adapter-tuning\n    │           ├── prefixtuning.py            # Code for prefix-tuning\n    │           └── combined_prefixtuning.py   # Code for combined prefix-tuning (not used in our paper, see Misc)\n    │\n    ├── seq2seq_construction                   # Code for converting raw data into sequences\n    │    └──  ...                              # Please check the README in this directory.\n    │\n    ├── tasks                                  # Code for loading raw data\n    │    └──  ...                              # Please check the README in this directory.\n    │\n    ├── third_party                            # Packages from third parties\n    │    └──  ...                              # Please check the README in this directory.\n    │\n    ├── utils                                  # Code for some (probably) useful stuff\n    │       ├── processor                      # Adopted from Tapex: the processor that handles table truncation and linearization\n            │        └──  ...            \n    │       ├── configure.py                   # Code for parsing config files in .\u002Fconfigure\n    │       ├── dataset.py                     # Code for converting input and output sequences into Datasets for training\n    │       ├── tool.py                        # Code for loading models, seq2seq constructors, and evaluators\n    │       ├── trainer.py                     # Code for EvaluationFriendlyTrainer. If you want make training-specific modifications, you may want to change something here.\n    │       └── training_arguments.py          # Code for seq2seq training arguments\n    │\n    ├── .gitignore                 \n    ├── .gitmodules                    \n    ├── py3.7pytorch1.8.yaml                   # Anaconda environment config file\n    ├── README.md                              # The README file you are looking at :)\n    └── train.py                               # Entry code, which controls train, eval, test, storage, and logging\n\n\n\n## Add a new task into UnifiedSKG\n\n(READMEs in `.\u002Ftasks`, `.\u002Fseq2seq_construction`, `.\u002Fmetrics`, `.\u002Fconfigure` can also be helpful)\n\n1. Add a \"Loader\" of raw data under `.\u002Ftasks`. You can search [HuggingFace Datasets](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdatasets) for possibly useful scripts. If not, you can be the contributor of both this project and the HuggingFace community.\n2. Add a \"Sequence Wrapper\" under `.\u002Fseq2seq_construction` to construct sequence inputs (user request and structured knowledge) and sequene outputs from raw data for the unification.\n3. Add an \"Evaluator\" for your task under `.\u002Fmetrics`. If a third-party repository is used, remember to add it into [.gitmodules](https:\u002F\u002Fgit-scm.com\u002Fdocs\u002Fgitmodules). \n4. *(optional)* You can add a new \"Model\" under `.\u002Fmodels` for a new model architecture or a new learning algorithm.\n5. Add a config file for your task under `.\u002Fconfigure\u002FMETA_TUNING`.\n6. Add a config file for each of your experiment under `.\u002Fconfigure\u002FSalesforce`.\n\n## Misc\n- We name the diretory for experimental config files as Salesforce because we would like to thank Salesforce Research for providing a large number of GPUs. We would also like to thank Amazon Research Awards, ServiceNow Research, and Yale NLP for providing computing resources generously. \n- `.\u002Fmodels\u002Funified\u002Fcombined_prefixtuning.py` is not used in our paper. This file contains code for the *interaction* between multiple prefixes in a single training loop. We tried some variants of such interaction but did not find any of them to outperform the (extremely simple) transfer learning-based approach used in our paper. However, we open-source our failed attempts and call for potential future exploration. \n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_7204e3758bef.png\" align=\"middle\" width=\"98%\">\n\n**That's all for it :D**\n\n## Citation\nIf you find our work helpful, please cite as\n```\n@article{UnifiedSKG,\n      title={UnifiedSKG: Unifying and Multi-Tasking Structured Knowledge Grounding with Text-to-Text Language Models}, \n      author={Tianbao Xie and Chen Henry Wu and Peng Shi and Ruiqi Zhong and Torsten Scholak and Michihiro Yasunaga and Chien-Sheng Wu and Ming Zhong and Pengcheng Yin and Sida I. Wang and Victor Zhong and Bailin Wang and Chengzu Li and Connor Boyle and Ansong Ni and Ziyu Yao and Dragomir Radev and Caiming Xiong and Lingpeng Kong and Rui Zhang and Noah A. Smith and Luke Zettlemoyer and Tao Yu},\n      journal={EMNLP},\n      year={2022},\n}\n```\n\n## Contributors\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FTimothyxxx\">  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_6ce0261a1fca.png\"  width=\"50\" \u002F>\u003C\u002Fa> \n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FChenWu98\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_ee1cb98f548e.png\"  width=\"50\" \u002F>\u003C\u002Fa> \n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FImpavidity\">  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_134439f19424.png\"  width=\"50\" \u002F>\u003C\u002Fa> \n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fmichiyasunaga\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_7603665e8c34.png\"  width=\"50\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fcascadianblue\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_df476e7be589.png\"  width=\"50\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fchengzu-li\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_2c8e6d4705ff.png\"  width=\"50\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fjasonwu0731\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_e041062ec892.png\"  width=\"50\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Fpulls\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_b7ee960e3558.jpg\"  width=\"50\" \u002F>\u003C\u002Fa>\n\n\n\n\n\n","# UnifiedSKG:书籍:: 使用文本到文本语言模型统一和多任务结构化知识接地\n\n\u003Cp align=\"left\">\n    \u003Ca href=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPRs-Welcome-red\">\n        \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPRs-Welcome-red\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flast-commit\u002FHKUNLP\u002FUnifiedSKG?color=green\">\n        \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flast-commit\u002FHKUNLP\u002FUnifiedSKG?color=green\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1f9yTXC3GpSyRJOjzsKceG_bhk-Cw71Ga#scrollTo=r_3-DN0SvC97\">\n        \u003Cimg alt=\"在Colab中打开\" src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\">\n    \u003C\u002Fa>\n    \u003Cbr\u002F>\n\u003C\u002Fp>\n\n这是EMNLP 2022（口头报告）论文[UnifiedSKG：使用文本到文本语言模型统一和多任务结构化知识接地](https:\u002F\u002Farxiv.org\u002Fabs\u002F2201.05966)的代码。请访问我们的[项目页面](https:\u002F\u002Funifiedskg.com\u002F)以获取最新的相关资源（例如论文、代码、工具、教程），用于结构化知识接地。您可以从[HuggingFace Model Hub](https:\u002F\u002Fhuggingface.co\u002Fhkunlp)加载我们的检查点。\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_7a774ae3558e.png\" align=\"middle\" width=\"100%\">\n\n**S**tructured **k**nowledge **g**rounding (**SKG**) 利用结构化知识来完成用户请求，例如对数据库进行语义解析以及对知识库进行问答。由于SKG任务的输入和输出是异构的，因此历史上一直由不同的研究群体分别研究，这限制了关于SKG的系统性和兼容性研究。在本文中，我们通过提出**UnifiedSKG框架**克服了这一局限性，该框架将**21个SKG任务**统一为文本到文本的形式，旨在推动系统的SKG研究，而不是局限于单一任务、领域或数据集。我们证明，像T5这样的大型语言模型，在必要时经过简单修改，可以在**几乎所有的21项任务上达到最先进的性能**。UnifiedSKG促进了**多任务学习**。我们发现，多任务前缀调优对大多数任务都有益处，大大提升了整体性能。UnifiedSKG还是一个具有挑战性的**零样本和少样本学习**测试平台，而T0、GPT-3和Codex在这方面表现不佳。此外，UnifiedSKG还允许在不同SKG任务中对**结构化知识编码**的不同变体进行一系列受控实验。我们发现，T5对结构化知识编码变化的敏感性因任务而异。\n\n**UnifiedSKG** 具有良好的可扩展性。我们非常欢迎您的**拉取请求**，以向UnifiedSKG添加数据集、设置、指标、模型以及新功能！\n\n## 更新\n- **2022-03-12**：如果您不想使用我们框架中的HuggingFace加载器，而是想自己尝试，可以查看UnifiedSKG为您处理好的seq2seq数据[这里](https:\u002F\u002Fdrive.google.com\u002Fdrive\u002Ffolders\u002F1GXigUv3MU-Sh4XiY6Wz3xVeNT_s0SuON)。\n- **2022-01-12**：我们发布了我们的[代码](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG)、[Colab演示](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1f9yTXC3GpSyRJOjzsKceG_bhk-Cw71Ga#scrollTo=r_3-DN0SvC97)、[权重](https:\u002F\u002Fhuggingface.co\u002Fhkunlp)和[项目页面](https:\u002F\u002Funifiedskg.com)。快来看看吧！\n\n## 内容\n\n- [UnifiedSKG：使用文本到文本语言模型统一和多任务**S**tructured **K**nowledge **G**rounding](#unifiedskgbooks-unifying-and-multi-tasking-structured-knowledge-grounding-with-text-to-text-language-models)\n  * [克隆此仓库](#cloning-this-repo)\n  * [依赖项](#dependencies)\n  * [使用方法](#usage)\n    + [环境设置](#environment-setup)\n    + [WandB设置](#wandb-setup)\n    + [训练](#training)\n    + [加载权重](#load-weights)\n  * 各目录简介\n    + [configure](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fconfigure)\n    + [metrics](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmetrics)\n    + [models](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmodels)\n    + [seq2seq_construction](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fseq2seq_construction)\n    + [third_party](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fthird_party)\n    + [utils](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Futils)\n  * [UnifiedSKG的代码结构概述](#code-structure-overview-of-unifiedskg)\n  * [向UnifiedSKG添加新任务](#add-a-new-task-into-unifiedskg)\n  * [杂项](#misc)\n  * [贡献者](#contributors)\n\n\n\n\n## 克隆此仓库\n\n为了包含此仓库中的第三方依赖项，请确保以递归方式克隆，例如：\n\n```\ngit clone --recurse-submodules git@github.com:HKUNLP\u002FUnifiedSKG.git\n```\n\n## 参考文献\n\n要建立环境，请在终端中运行以下命令（第三行适用于CUDA11.1）：\n\n``````\nconda env create -f py3.7pytorch1.8.yaml\nconda activate py3.7pytorch1.8new\npip install datasets==1.14.0\n# 根据您的CUDA版本替换以下行。\npip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Ftorch_stable.html\n``````\n\n这将创建我们使用的环境`py3.7pytorch1.8new`。\n\n\u003C!--\n### 子模块\n\n一些存储在子模块中的第三方库需要安装\n\n#### ~~TaPEx~~（我们将其表格处理器整合到代码中并进行了一些修改）\n\n~~对于TaPEx，您可以运行~~\n\n```\ncd third_party\u002Ftable_pretraining\u002F\npip install --editable .\u002F\ncd ..\u002F..\n```\n\n\n#### TaBERT\n\n在激活conda环境并*安装UniPSP的主要依赖项后*，运行以下命令：\n``````\npip install --editable=git+https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Ftransformers.git@372a5c1ceec49b52c503707e9657bfaae7c236a0#egg=pytorch_pretrained_bert fairseq==0.8.0 torch-scatter==1.3.2 ujson msgpack redis zmq h5py\n``````\n\n然后，导航到TaBERT目录并安装它：\n\n``````\ncd third_party\u002Ftabert\u002F\npip install --editable .\u002F\ncd ..\u002F..\n``````\n\n如果您在统一过程中对环境或命令进行了更多修改，\n请在本README下方的方框中注明：\n\n``````\n*add*me*\n``````\n我们将在最后将它们打包成Docker环境。\n\n-->\n\n## 使用方法\n\n### 环境设置\n通过运行以下命令激活环境：\n``````shell\nconda activate py3.7pytorch1.8new\n``````\n\n### WandB设置\n\n设置[WandB](https:\u002F\u002Fwandb.ai\u002F)进行日志记录（需注册）：\n``````shell\nexport WANDB_API_KEY=YOUR_WANDB_API_KEY\nexport WANDB_PROJECT=YOUR_PROJECT_NAME\nexport WANDB_ENTITY=YOUR_TEAM_NAME\n``````\n\n### 训练\n\nT5-base 在 WikiTQ 上的微调（4 张 GPU，有效批次大小 128）\n``````shell\npython -m torch.distributed.launch --nproc_per_node 4 --master_port 1234 train.py --seed 2 --cfg Salesforce\u002FT5_base_finetune_wikitq.cfg --run_name T5_base_finetune_wikitq --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 500 --metric_for_best_model avr --greater_is_better true --save_strategy steps --save_steps 500 --save_total_limit 1 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 400 --adafactor true --learning_rate 5e-5 --do_train --do_eval --do_predict --predict_with_generate --output_dir output\u002FT5_base_finetune_wikitq --overwrite_output_dir --per_device_train_batch_size 4 --per_device_eval_batch_size 16 --generation_num_beams 4 --generation_max_length 128 --input_max_length 1024 --ddp_find_unused_parameters true\n``````\n如果你想恢复训练，只需从上述命令中移除 ``--overwrite_output_dir`` 标志：\n``````shell\npython -m torch.distributed.launch --nproc_per_node 4 --master_port 1234 train.py --seed 2 --cfg Salesforce\u002FT5_base_finetune_wikitq.cfg --run_name T5_base_finetune_wikitq --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 500 --metric_for_best_model avr --greater_is_better true --save_strategy steps --save_steps 500 --save_total_limit 1 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 400 --adafactor true --learning_rate 5e-5 --do_train --do_eval --do_predict --predict_with_generate --output_dir output\u002FT5_base_finetune_wikitq --per_device_train_batch_size 4 --per_device_eval_batch_size 16 --generation_num_beams 4 --generation_max_length 128 --input_max_length 1024 --ddp_find_unused_parameters true\n``````\n\nT5-base 在 WikiTQ 上的前缀微调（4 张 GPU，有效批次大小 128）\n``````shell\npython -m torch.distributed.launch --nproc_per_node 4 --master_port 1234 train.py --seed 2 --cfg Salesforce\u002FT5_base_prefix_wikitq.cfg --run_name T5_base_prefix_wikitq --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 500 --metric_for_best_model avr --greater_is_better true --save_strategy steps --save_steps 500 --save_total_limit 1 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 400 --adafactor true --learning_rate 5e-5 --do_train --do_eval --do_predict --predict_with_generate --output_dir output\u002FT5_base_prefix_wikitq --overwrite_output_dir --per_device_train_batch_size 4 --per_device_eval_batch_size 16 --generation_num_beams 4 --generation_max_length 128 --input_max_length 1024 --ddp_find_unused_parameters true\n``````\n\nT5-3b 在 WikiTQ 上的微调（8 张 GPU，有效批次大小 128）\n``````shell\ndeepspeed train.py --deepspeed deepspeed\u002Fds_config_zero2.json --seed 2 --cfg Salesforce\u002FT5_3b_finetune_wikitq.cfg --run_name T5_3b_finetune_wikitq --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 500 --metric_for_best_model avr --greater_is_better true --save_strategy steps --save_steps 500 --save_total_limit 1 --load_best_model_at_end --gradient_accumulation_steps 16 --num_train_epochs 50 --adafactor false --learning_rate 5e-5 --do_train --do_eval --do_predict --predict_with_generate --output_dir output\u002FT5_3b_finetune_wikitq --overwrite_output_dir --per_device_train_batch_size 1 --per_device_eval_batch_size 1 --generation_num_beams 4 --generation_max_length 128 --input_max_length 1024 --ddp_find_unused_parameters true\n``````\n\n### 加载权重\n请参阅 \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1f9yTXC3GpSyRJOjzsKceG_bhk-Cw71Ga#scrollTo=r_3-DN0SvC97\">\n        \u003Cimg alt=\"在 Colab 中打开\" src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\">\n    \u003C\u002Fa>\n \n\u003C!--\n## 各文件简介\n\n### [configure](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fconfigure)\n\n用于配置不同任务\u002F设置的代码，更多详情请参阅 [.\u002Fconfigure](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fconfigure) 中的 README。\n\n### [metrics](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmetrics)\n用于评估我们模型预测结果的代码，更多详情请参阅 [.\u002Fmetrics](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmetrics) 中的 README。\n\n### [models](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fmodels)\n模型代码（目前包括序列到序列模型（T5 和 BART）以及提示微调模型（前缀微调））。\n\n### [seq2seq_construction](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fseq2seq_construction)\n用于评估我们模型预测结果的代码，更多详情请参阅 [.\u002Fseq2seq_construction](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fseq2seq_construction) 中的 README。\n\n### [third_party](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Fthird_party)\n第三方提供的软件包，供我们临时存放，最终将通过 Git 递归部署进行重定向。\n\n### [utils](https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Ftree\u002Fmaster\u002Futils)\n包含一些实用（或不那么实用）工具的代码，具体如下：\n- **configure.py**: 用于解析和存储 .\u002Fconfigure 目录下配置文件的“args”数据结构。（我们正尝试将其改造成更主流的结构，使其也能支持从文件读取并创建嵌套的配置对象。）\n- **dataset.py**: 包装序列到序列数据集，对“seq_in”和“seq_out”进行分词处理，因为训练器仅支持以分词后的“seq_input”和“seq_output”张量作为输入。\n- **tool.py**: 用于以统一方式获取数据集、模型和评估器的工具。\n- **trainer.py**: Hugging Face 训练器类的修改版本，旨在支持元微调（我们希望掌控自己的训练采样器）、更便捷的评估（Hugging Face 输入格式的指标数值与官方评估标准相矛盾）以及本项目中的进一步改进（例如，我们希望在模型的 forward 函数中传递更多参数）。\n- **training_arguments.py**: 自定义封装的训练参数。\n\n### train.py\n- 结合配置文件，作为实验的起点和主要控制中心。\n\n### 流程\n我们的工作流程如下：原始数据 -> 序列到序列数据（“seq_in”和“seq_out”） -> 分词 -> 序列到序列训练器 -> 预测 -> 评估(s)\n-->\n\n## UnifiedSKG 的代码结构概览\n    .\n    ├── configure                              # 用于实验、任务和设置的配置文件\n    │   ├── META_TUNING                        # 任务和设置的配置文件\n    │   └── Salesforce                         # 实验的配置文件（见杂项）\n    │\n    ├── metrics                                # 评估相关代码\n    │   └── ...                                # 请查看 .\u002Fseq2seq_construction 目录下的 README。\n    ├── models                                 # 模型相关代码\n    │   ├── adapter                            # 基于 HuggingFace Transformers 的带有适配器的 T5 和 BART 模型代码\n    │   ├── prompt                             # 基于 HuggingFace Transformers 的带有前缀调优的 T5 和 BART 模型代码\n    │   └── unified\n    │           ├── base.py                    # 使任意模型能够推送到 HuggingFace Model Hub 的基础模型代码（即 PushToHubFriendlyModel）\n    │           ├── finetune.py                # 微调相关代码\n    │           ├── adaptertuning.py           # 适配器调优相关代码\n    │           ├── prefixtuning.py            # 前缀调优相关代码\n    │           └── combined_prefixtuning.py   # 组合前缀调优相关代码（未在我们的论文中使用，见杂项）\n    │\n    ├── seq2seq_construction                   # 将原始数据转换为序列的代码\n    │    └──  ...                              # 请查看该目录下的 README。\n    │\n    ├── tasks                                  # 加载原始数据的代码\n    │    └──  ...                              # 请查看该目录下的 README。\n    │\n    ├── third_party                            # 第三方库\n    │    └──  ...                              # 请查看该目录下的 README。\n    │\n    ├── utils                                  # 一些（可能）有用的工具代码\n    │       ├── processor                      # 引用自 Tapex：处理表格截断和线性化的处理器\n            │        └──  ...\n    │       ├── configure.py                   # 解析 .\u002Fconfigure 目录下配置文件的代码\n    │       ├── dataset.py                     # 将输入和输出序列转换为训练用数据集的代码\n    │       ├── tool.py                        # 加载模型、seq2seq 构造器和评估器的代码\n    │       ├── trainer.py                     # EvaluationFriendlyTrainer 的代码。如果需要对训练进行特定修改，可以在此处调整。\n    │       └── training_arguments.py          # seq2seq 训练参数的代码\n    │\n    ├── .gitignore                 \n    ├── .gitmodules                    \n    ├── py3.7pytorch1.8.yaml                   # Anaconda 环境配置文件\n    ├── README.md                              # 你正在阅读的 README 文件 :)\n    └── train.py                               # 入口代码，负责控制训练、评估、测试、存储和日志记录\n\n\n\n## 在 UnifiedSKG 中添加新任务\n\n（`.\u002Ftasks`、`.\u002Fseq2seq_construction`、`.\u002Fmetrics`、`.\u002Fconfigure` 目录下的 README 也可能有所帮助）\n\n1. 在 `.\u002Ftasks` 下添加一个原始数据加载器。你可以搜索 [HuggingFace Datasets](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdatasets) 查找可能有用的脚本。如果没有，你也可以为该项目和 HuggingFace 社区做出贡献。\n2. 在 `.\u002Fseq2seq_construction` 下添加一个“序列包装器”，用于从原始数据中构建统一的序列输入（用户请求和结构化知识）和序列输出。\n3. 在 `.\u002Fmetrics` 下为你的任务添加一个“评估器”。如果使用了第三方库，请记得将其添加到 [.gitmodules](https:\u002F\u002Fgit-scm.com\u002Fdocs\u002Fgitmodules) 中。\n4. *(可选)* 你可以在 `.\u002Fmodels` 下添加一个新的“模型”，以支持新的模型架构或新的学习算法。\n5. 在 `.\u002Fconfigure\u002FMETA_TUNING` 下为你的任务添加一个配置文件。\n6. 在 `.\u002Fconfigure\u002FSalesforce` 下为你的每个实验添加一个配置文件。\n\n## 杂项\n- 我们将实验配置文件的目录命名为 Salesforce，是因为我们要感谢 Salesforce Research 提供了大量的 GPU 资源。我们还要感谢 Amazon Research Awards、ServiceNow Research 和 Yale NLP 慷慨地提供了计算资源。\n- `.\u002Fmodels\u002Funified\u002Fcombined_prefixtuning.py` 并未在我们的论文中使用。该文件包含在一个训练循环中多个前缀之间“交互”的代码。我们尝试过多种此类交互方式，但没有发现任何一种能超越我们论文中采用的（极其简单）基于迁移学习的方法。不过，我们将这些失败的尝试开源，并呼吁未来的研究者继续探索。\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_7204e3758bef.png\" align=\"middle\" width=\"98%\">\n\n**就到这里啦 :D**\n\n## 引用\n如果你觉得我们的工作对你有帮助，请按以下格式引用：\n```\n@article{UnifiedSKG,\n      title={UnifiedSKG: Unifying and Multi-Tasking Structured Knowledge Grounding with Text-to-Text Language Models}, \n      author={Tianbao Xie and Chen Henry Wu and Peng Shi and Ruiqi Zhong and Torsten Scholak and Michihiro Yasunaga and Chien-Sheng Wu and Ming Zhong and Pengcheng Yin and Sida I. Wang and Victor Zhong and Bailin Wang and Chengzu Li and Connor Boyle and Ansong Ni and Ziyu Yao and Dragomir Radev and Caiming Xiong and Lingpeng Kong and Rui Zhang and Noah A. Smith and Luke Zettlemoyer and Tao Yu},\n      journal={EMNLP},\n      year={2022},\n}\n```\n\n## 贡献者\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FTimothyxxx\">  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_6ce0261a1fca.png\"  width=\"50\" \u002F>\u003C\u002Fa> \n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FChenWu98\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_ee1cb98f548e.png\"  width=\"50\" \u002F>\u003C\u002Fa> \n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FImpavidity\">  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_134439f19424.png\"  width=\"50\" \u002F>\u003C\u002Fa> \n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fmichiyasunaga\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_7603665e8c34.png\"  width=\"50\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fcascadianblue\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_df476e7be589.png\"  width=\"50\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fchengzu-li\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_2c8e6d4705ff.png\"  width=\"50\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fjasonwu0731\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_e041062ec892.png\"  width=\"50\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FHKUNLP\u002FUnifiedSKG\u002Fpulls\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_readme_b7ee960e3558.jpg\"  width=\"50\" \u002F>\u003C\u002Fa>","# UnifiedSKG 快速上手指南\n\nUnifiedSKG 是一个基于 Text-to-Text 语言模型的统一框架，旨在将 21 种结构化知识接地（SKG）任务（如语义解析、知识库问答等）统一为文本生成格式，支持多任务学习和少样本\u002F零样本学习。\n\n## 环境准备\n\n*   **操作系统**: Linux (推荐)\n*   **Python 版本**: 3.7\n*   **深度学习框架**: PyTorch 1.8.0\n*   **CUDA 版本**: 推荐 11.1 (需根据实际显卡驱动调整)\n*   **硬件要求**: 训练建议使用多 GPU 环境；推理可使用单 GPU 或 CPU。\n\n## 安装步骤\n\n### 1. 克隆仓库\n由于项目包含第三方子模块，请务必使用 `--recurse-submodules` 参数进行克隆：\n\n```bash\ngit clone --recurse-submodules git@github.com:HKUNLP\u002FUnifiedSKG.git\ncd UnifiedSKG\n```\n\n### 2. 创建 Conda 环境\n使用项目提供的配置文件创建环境：\n\n```bash\nconda env create -f py3.7pytorch1.8.yaml\nconda activate py3.7pytorch1.8new\n```\n\n### 3. 安装依赖\n安装 `datasets` 库及对应 CUDA 版本的 PyTorch（以下命令针对 CUDA 11.1，其他版本请自行替换）：\n\n```bash\npip install datasets==1.14.0\npip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Ftorch_stable.html\n```\n\n> **国内加速提示**：如果下载速度慢，建议在 `pip` 命令后添加 `-i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple` 使用清华镜像源。PyTorch 官方源若连接困难，可尝试寻找国内维护的 wheel 包镜像。\n\n### 4. 配置 WandB (可选但推荐)\n用于记录训练日志，需先在 [WandB](https:\u002F\u002Fwandb.ai\u002F) 注册账号并获取 API Key：\n\n```bash\nexport WANDB_API_KEY=YOUR_WANDB_API_KEY\nexport WANDB_PROJECT=YOUR_PROJECT_NAME\nexport WANDB_ENTITY=YOUR_TEAM_NAME\n```\n\n## 基本使用\n\n### 加载预训练模型进行推理\n最简便的方式是通过 Google Colab 直接体验或加载 HuggingFace 上的权重。\n\n**方式一：使用 Colab 演示**\n点击以下链接直接在浏览器中运行示例，无需本地配置环境：\n[Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1f9yTXC3GpSyRJOjzsKceG_bhk-Cw71Ga#scrollTo=r_3-DN0SvC97)\n\n**方式二：本地加载权重**\n模型权重已托管在 HuggingFace Model Hub (`hkunlp`)。你可以在代码中直接通过 `transformers` 库加载：\n\n```python\nfrom transformers import AutoModelForSeq2SeqLM, AutoTokenizer\n\nmodel_name = \"hkunlp\u002Funifiedskg-t5-base\" # 示例模型名称，具体请参考 HF 页面\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModelForSeq2SeqLM.from_pretrained(model_name)\n\ninput_text = \"translate English to SQL: How many employees are there?\"\ninputs = tokenizer(input_text, return_tensors=\"pt\")\n\noutputs = model.generate(**inputs)\nresult = tokenizer.decode(outputs[0], skip_special_tokens=True)\nprint(result)\n```\n\n### 训练示例\n以下是在 WikiTQ 数据集上使用 4 张 GPU 对 T5-base 进行微调的命令示例：\n\n```bash\npython -m torch.distributed.launch --nproc_per_node 4 --master_port 1234 train.py --seed 2 --cfg Salesforce\u002FT5_base_finetune_wikitq.cfg --run_name T5_base_finetune_wikitq --logging_strategy steps --logging_first_step true --logging_steps 4 --evaluation_strategy steps --eval_steps 500 --metric_for_best_model avr --greater_is_better true --save_strategy steps --save_steps 500 --save_total_limit 1 --load_best_model_at_end --gradient_accumulation_steps 8 --num_train_epochs 400 --adafactor true --learning_rate 5e-5 --do_train --do_eval --do_predict --predict_with_generate --output_dir output\u002FT5_base_finetune_wikitq --overwrite_output_dir --per_device_train_batch_size 4 --per_device_eval_batch_size 16 --generation_num_beams 4 --generation_max_length 128 --input_max_length 1024 --ddp_find_unused_parameters true\n```\n\n如需断点续训，请移除上述命令中的 `--overwrite_output_dir` 标志。","某电商数据团队需要构建一个智能助手，让用户能直接用自然语言查询复杂的商品数据库（如“找出价格低于 500 元且评分高于 4.5 的蓝牙耳机”）以及关联的品牌知识图谱。\n\n### 没有 UnifiedSKG 时\n- **开发割裂严重**：团队需分别为数据库语义解析和知识库问答训练两套独立模型，代码库互不兼容，维护成本极高。\n- **数据格式混乱**：处理异构的结构化数据（SQL 表、RDF 图谱）时，需编写大量定制化预处理脚本，难以统一为标准文本格式。\n- **小样本效果差**：面对新推出的商品类别，由于缺乏标注数据，传统模型在零样本或少样本场景下几乎无法准确理解用户意图。\n- **泛化能力受限**：单一任务模型无法利用其他相关任务的知识，导致在处理跨域复杂查询时准确率低下。\n\n### 使用 UnifiedSKG 后\n- **架构统一高效**：UnifiedSKG 将 21 类结构化知识任务全部转化为统一的文本到文本格式，仅需一套 T5 模型即可同时处理数据库查询与知识问答。\n- **流程标准化**：内置的数据构造模块自动将异构的结构化知识编码为模型可理解的序列，消除了繁琐的手工特征工程。\n- **少样本表现卓越**：得益于多任务前缀微调（Multi-task Prefix-tuning），UnifiedSKG 在仅有少量示例的新商品场景中，依然能保持高精度的推理能力。\n- **知识迁移增强**：模型在不同任务间共享结构化知识表示，显著提升了面对复杂跨域查询时的系统鲁棒性与准确率。\n\nUnifiedSKG 通过统一框架打破了结构化知识落地的任务壁垒，让开发者能用一套模型低成本实现多场景、高精度的智能数据交互。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxlang-ai_UnifiedSKG_7204e375.png","xlang-ai","XLANG Lab","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fxlang-ai_02033ec0.png","Developing embodied AI agents that empower users to use language to interact with digital and physical environments to carry out real-world tasks.",null,"XLangNLP","https:\u002F\u002Fxlang.ai","https:\u002F\u002Fgithub.com\u002Fxlang-ai",[84,88],{"name":85,"color":86,"percentage":87},"Python","#3572A5",99.8,{"name":89,"color":90,"percentage":91},"Dockerfile","#384d54",0.2,569,61,"2026-03-16T17:38:00","Apache-2.0",4,"Linux","必需 NVIDIA GPU。示例命令显示支持 CUDA 11.1 (cu111)。训练 T5-base 需 4 张 GPU，训练 T5-3b 需 8 张 GPU（配合 DeepSpeed Zero2），单卡显存需求视模型大小和 batch size 而定（T5-3b 示例中单卡 batch size 为 1）。","未说明",{"notes":101,"python":102,"dependencies":103},"1. 必须使用 git clone --recurse-submodules 克隆仓库以包含第三方依赖。2. 需配置 WandB (Weights & Biases) API Key 用于日志记录。3. 大模型训练（如 T5-3b）需安装并配置 DeepSpeed。4. 部分第三方模块（如 TaBERT）需要单独进入目录进行可编辑安装。5. 官方提供的环境配置文件为 py3.7pytorch1.8.yaml。","3.7",[104,105,106,107,108,109,110,111,112,113],"torch==1.8.0+cu111","torchvision==0.9.0+cu111","torchaudio==0.8.0","datasets==1.14.0","transformers (特定 commit 372a5c1)","fairseq==0.8.0","torch-scatter==1.3.2","ujson","msgpack","redis",[14,13,26,51],[116,117,118,119,120,121,122,123,124,125,126,127,128],"natural-language-processing","pytorch","huggingface-transformers","huggingface-datasets","structured-knowledge-grounding","semantic-parsing","question-answering","data-to-text","text-generation","fact-verification","multi-task-learning","prompt-learning","nlp","2026-03-27T02:49:30.150509","2026-04-06T10:25:14.518743",[132,137,142,147,152,157],{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},12848,"如何设置 GPU 数量和批次大小（Batch Size）？","GPU 数量通过启动命令中的 `--nproc_per_node` 参数设置，例如 `--nproc_per_node 4` 表示使用 4 张 GPU。总批次大小等于 `--nproc_per_node` 乘以 `--per_device_train_batch_size`。例如，若设置 `--nproc_per_node 4` 且 `--per_device_train_batch_size 32`，则总批次大小为 128。","https:\u002F\u002Fgithub.com\u002Fxlang-ai\u002FUnifiedSKG\u002Fissues\u002F11",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},12849,"如何运行原始的 Prefix-tuning（Li & Liang 论文版本）？","要运行基础的 Prefix-tuning 版本，请在配置中不要设置 `knowledge_usage` 参数（或保持默认），并将 `use_description` 设置为 `False`。如果是单任务训练，确保数据加载器中的 `struct_in` 设置为空字符串 \"\"。其他如 `concatenate_description` 等参数仅用于多任务特定设置，基础版本无需启用。","https:\u002F\u002Fgithub.com\u002Fxlang-ai\u002FUnifiedSKG\u002Fissues\u002F34",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},12850,"遇到 NCCL、PyTorch 和 CUDA 版本冲突或分布式训练报错怎么办？","如果遇到分布式训练相关的错误（如端口冲突或 NCCL 问题），尝试重置环境变量中的 `PORT` 和 `RDVZ_ID`。此外，可以先运行一个最小化的分布式训练示例代码来验证机器环境是否正常，以排除是代码逻辑问题还是环境配置问题。","https:\u002F\u002Fgithub.com\u002Fxlang-ai\u002FUnifiedSKG\u002Fissues\u002F12",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},12851,"如何在本地指定已下载的预训练模型（PLM）文件夹路径？","由于网络问题无法自动下载模型时，可以手动下载模型文件。在 YAML 配置文件中，将模型位置（通常对应 `bert.location` 或类似的模型路径字段）直接修改为本地已下载模型的文件夹绝对路径即可，程序会直接从该路径加载模型而不再尝试下载。","https:\u002F\u002Fgithub.com\u002Fxlang-ai\u002FUnifiedSKG\u002Fissues\u002F19",{"id":153,"question_zh":154,"answer_zh":155,"source_url":156},12852,"使用 T5-3B 模型进行 Prefix Tuning 时出现显存溢出（OOM）或张量尺寸不匹配错误如何解决？","T5-3B 模型非常大，即使在 40GB 显存的 GPU 上，单卡运行也极易导致 OOM（显存溢出）。建议使用多张 GPU 进行分布式训练，或者集成 DeepSpeed 库来进行优化。对于张量尺寸不匹配的错误，这通常是特定于大模型实现的 Bug，使用多卡环境或检查特定的 prefix tuning 代码实现可能有助于解决。","https:\u002F\u002Fgithub.com\u002Fxlang-ai\u002FUnifiedSKG\u002Fissues\u002F27",{"id":158,"question_zh":159,"answer_zh":160,"source_url":161},12853,"即使只使用 1 张 GPU（n_gpus=1），train.py 是否默认使用 DDP 训练？","是的，脚本设计支持 DDP 模式。但需要注意的是，对于像 T5-3B 这样的大模型，即使是在单张 32GB V100 GPU 上，通常也需要配合 DeepSpeed 才能正常运行，否则可能会因为显存不足而失败。","https:\u002F\u002Fgithub.com\u002Fxlang-ai\u002FUnifiedSKG\u002Fissues\u002F25",[]]