Skip to content

[RFC][请勿合并] 改进 Noesis 从句拆分与 fenced JSON 解析 - #1

Open
valenpras wants to merge 8 commits into
4iKZ:mainfrom
valenpras:fix/noesis-prompt-clause-split
Open

valenpras wants to merge 8 commits into
4iKZ:mainfrom
valenpras:fix/noesis-prompt-clause-split

Conversation

@valenpras

Copy link
Copy Markdown
Collaborator

Caution

请勿合并此 PR。

这是一个仅供评审的 Draft PR。当前实现已修复已报告的回归问题,但仍包含针对特定输入的 prompt 约束和已知语义局限。任何合并决定都必须经过技术与语言层面的评审。

基线

本工作基于 Hyper-Extract 提交 a9a5e0a,即当前 wxs-noesis 固定使用的版本。

概述

本次修改调查并改进了 Noesis 对嵌套实际事件的抽取行为。

此前,模型可能把包含动作或状态谓词的完整从句保留为一个较大的 E atom,而不是提取其中的谓词及其语义层级。

此外,本次修改还增加了对 LLM 返回 Markdown JSON 代码围栏的窄范围处理。

修改内容

  • 增加通用约束:一个 atom 应只表示一个语义概元。
  • 防止包含独立动作或状态的小句被整体输出为一个大 E atom。
  • 明确区分实际断言事件与名词性短语。
  • 明确嵌套事件之间的时间挂接关系。
  • 为已报告输入增加明确标注的回归约束。
  • 将回归约束与三个权威示例分开,避免被误认为通用语法规则。
  • 在 JSON 解析前增加窄范围的最外层 Markdown fence 移除。
  • 增加针对 prompt 和解析行为的确定性回归测试。

主要涉及文件:

  • hyperextract/noesis/prompt.py
  • hyperextract/noesis/extractor.py
  • tests/noesis/test_extractor.py
  • tests/noesis/test_edge_and_tree_structure.py

验证结果

已记录的确定性测试结果:

uv run pytest tests/noesis -q
213 passed

4iKZ and others added 8 commits September 4, 2026 20:30
Clarify that coordinate predicates remain independent event closures even when they share a subject, time, or context.

Add a fourth authoritative prompt example and golden fixture for splitting sitting, eating, and phone-use actions into separate components. Preserve strict single-root target_occ semantics and prevent aggregate-plus-split duplicate output.

Cover the prompt contract and validator-compatible three-component projection with regression tests.
Adopt the authoritative three-example prompt, resolved tri-state fields, nested predicate closure rules, and bounded deterministic repairs. Reject external Genemes, preserve source fidelity in rule templates while allowing source-backed composite expressions, and add regression coverage for retry and target repair semantics.
Forbid gluing a verb-bearing clause into one E. Content of 显示/喜欢 goes in tree.nested; verb-free time like 昨天晚上 stays one modifier E. Still exactly three canonical examples.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants