Skip to content

Fix missing optional dependency for matching example (annoy)#204

Open
Mountain-Biker wants to merge 1 commit intodatawhalechina:mainfrom
Mountain-Biker:docs/documentation-update
Open

Fix missing optional dependency for matching example (annoy)#204
Mountain-Biker wants to merge 1 commit intodatawhalechina:mainfrom
Mountain-Biker:docs/documentation-update

Conversation

@Mountain-Biker
Copy link
Copy Markdown

Pull Request / 拉取请求

What does this PR do? / 这个PR做了什么?

当我在运行README 文档中“快速开始”中的示例时,我发现了一个bug
Screenshot 2026-03-14 at 7 46 07 PM

我发现原因在于pyproject.toml 中,annoy 在optional dependencies list 中,所以 uv sync 并不会安装annoy。
为了解决这个问题,需要手动安装uv pip install ".[annoy]"

由于我们通过uv配置环境,所以在运行程序时应该用uv run 运行代码。

Type of Change / 变更类型

  • 📝 Documentation / 文档

Related Issues / 相关Issues

Fixes #(issue number) / 修复 #(issue编号)

How to Test / 如何测试

# 克隆仓库(如果使用最新版)
git clone https://github.com/datawhalechina/torch-rechub.git
cd torch-rechub
uv sync

# 安装 optinal dependency Annoy
uv pip install ".[annoy]"

# 运行召回示例(需要先进入对应目录,脚本使用相对路径加载数据)
cd examples/matching
uv run python run_ml_dssm.py

# 或使用自定义参数:
uv run python run_ml_dssm.py --model_name dssm --device 'cuda:0' --learning_rate 0.001 --epoch 50 --batch_size 4096 --weight_decay 0.0001 --save_dir 'saved/dssm_ml-100k'

# 运行精排示例
cd ../ranking
uv run python run_criteo.py

Checklist / 检查清单

  • Code follows project style (ran python config/format_code.py) / 代码遵循项目风格(运行了格式化脚本)
  • Added tests for new functionality / 为新功能添加了测试
  • Updated documentation if needed / 如需要已更新文档
  • All tests pass locally / 所有测试在本地通过

Additional Notes / 附加说明

Any other information for reviewers / 给审查者的其他信息

@github-actions github-actions bot added documentation Improvements or additions to documentation | 文档更新 bug Something isn't working | Bug 修复 labels Mar 15, 2026
@1985312383
Copy link
Copy Markdown
Collaborator

Hi,很高兴你能选择来PR

不过这么做有个问题,在annoy安装时,需要C++环境才可以被编译,会影响使用pip直接安装该库。所以关于Annoy的安装放在文档里有介绍link。另外我们同时支持三种向量数据库的插入操作,Anooy这么做后,其他两个也需要设置这些,为了一个库做一个单独的分组这很奇怪。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working | Bug 修复 documentation Improvements or additions to documentation | 文档更新

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants