Skip to content

feat: HF Daily Papers + arXiv 关键词/语义双通道论文信源 - #80

Open
CylenLC wants to merge 1 commit into
iHeadWater:mainfrom
CylenLC:feat/hf-arxiv-dual-channel
Open

feat: HF Daily Papers + arXiv 关键词/语义双通道论文信源#80
CylenLC wants to merge 1 commit into
iHeadWater:mainfrom
CylenLC:feat/hf-arxiv-dual-channel

Conversation

@CylenLC

@CylenLC CylenLC commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Closes #12

概述

#12 的双通道设计实现论文信源:通道 A 社区热度(HF Daily Papers) + 通道 B 关键词/语义筛选(arXiv),两通道并列生成、各自去重,同属 arxiv 分类推送。

通道 A:HuggingFace Daily Papers

新增 hf_daily_paperstype: api),三个要点:

按发布日抓取。/api/daily_papers?date=YYYY-MM-DD 取某一天的页面,而不是无参端点返回的滚动 50 条热榜。实测差异:无参端点的 publishedAt 跨 5 天,会把几天前的论文混进当天简报。

周末不产出(weekdays_only)。 HF 只在周一至周五发布,周六日返回 HTTP 200 + 空列表(实测:周六/周日 0 篇,周一 13 / 周五 26)。这一层拦截必须放在 fetch() 之前——如果只让 fetch 返回空列表,会落进 _process_regular_source 的 placeholder 分支,push_to_discord 再把占位文件当"📭 今日无文章更新"发到频道,等于周末照样推送。所以用 DataSource.skips_today() 在两条调用路径(通用路径 + run_pipeline_arxiv,后者先 fetch)前短路,周末一个文件都不写。

不限数量。 top_percent: 100,取当天全量而非投票前 N 篇。注意解析处仅在 max_items缺失时才不设上限(兄弟解析器默认 25/20),所以是删键生效。max_articles_per_batch: 10 保留,它限制单次 AI 调用的 prompt 规模,不限覆盖范围。

通道 B:arXiv 关键词 + 向量召回

  • scripts/paper_retrieval.py — 关键词/短语匹配,词边界语义(watermark 不误命中 watermarking),含 lexical_embedding_union 策略
  • scripts/embedding_retrieval.py + qwen_embedding_service.py — 可选的本地 llama.cpp 向量后端
  • scripts/text_match.py — 两条 pipeline 共用一个短语匹配器
  • exclude_phrases跨通道硬否决,被否决的论文不会从向量通道绕回来

两通道各自维护 seen 状态,同一篇论文不会重复推送。

验证

  • pytest251 passed, 1 skipped(跳过项为 fastapi 未安装,与本 PR 无关)
  • ruff check scripts/ tests/ — All checks passed
  • 生产配置直连 HF API 实测:周一 13 篇 / 周五 26 篇 / 周六日 0 篇且不发请求
  • 周末测试做了反向验证:临时禁用守卫后该测试确实失败(assert 1 == 0),因此它钉住的是"不写文件、不推送"这个行为,而非仅返回值

⚠️ 与 PR #79 的范围重叠,需要 maintainer 决定合并顺序

这个分支的 diff 包含了 OpenReview 顶会 pipelinescripts/conference.py +1840、scripts/openreview_provider.py +452 及其测试),也就是 #79 的范围。原因是两条工作线共享祖先 1da1d0c,而 run_pipelines.py:27 无条件 from conference import ...upstream/main 又没有 conference.py,剔除会直接 import 失败——因此无法在本分支内干净剥离。

而且本分支的 conference 代码是较旧的一支#79conference.py 有 2686 行,本分支只有 1840 行。若先合本 PR,会覆盖 #79 上更新的实现。

建议先合 #79,我再把本 PR rebase 到其之上,只保留 #12 的双通道改动(paper_retrieval.py / embedding_retrieval.py / text_match.py / datasource.py / config/sources.json 等,这些文件均不依赖 conference 模块,已验证)。听 maintainer 安排。

…r sources

Implements the two-channel paper discovery described in iHeadWater#12.

Channel A -- Hugging Face Daily Papers (community heat):
  * New api source hf_daily_papers, fetched per publication day via
    /api/daily_papers?date=YYYY-MM-DD so a run reports one specific day
    rather than the rolling 50-entry board the bare endpoint returns.
  * weekdays_only: HF publishes Mon-Fri; Sat/Sun return HTTP 200 with an
    empty list. Guarded upstream of fetch so no briefing file is written
    at all -- an empty fetch would otherwise reach the placeholder branch
    and push a "no updates" notice to Discord on weekends.
  * No count cap: top_percent 100 keeps the full day (13-26 papers
    observed) instead of the top N by upvotes.

Channel B -- arXiv keyword + embedding retrieval:
  * scripts/paper_retrieval.py: keyword/phrase matching with word-boundary
    semantics, plus lexical_embedding_union strategy.
  * scripts/embedding_retrieval.py + qwen_embedding_service.py: optional
    local llama.cpp embedding backend for semantic recall.
  * scripts/text_match.py: one phrase matcher shared by both pipelines.
  * exclude_phrases acts as a cross-channel hard veto, so a vetoed paper
    cannot re-enter through the embedding channel.

Both channels write to the shared arxiv category and dedupe against
per-source seen state, so the same paper is not pushed twice.

Verified: pytest 251 passed / 1 skipped (skip = fastapi absent), ruff clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 集成 HuggingFace Daily Papers + arXiv 关键词筛选双通道论文信源

1 participant