DocumentJoiner positional weights follow Variadic arrival order, not connect() order

オープン
#12,646 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #12647 @coder058 による — マージされずにクローズ

評価

この issue はまだ評価されていません。

説明

handled internally P3

Describe the bug

DocumentJoiner weights=[w0, w1, …] are zipped positionally onto the Variadic documents list. That list order is not Pipeline.connect() order:

  • sync run: independent senders run in alphabetical component-name order, so weights bind to alphabetical arrival
  • run_async: completion/arrival order (nondeterministic)

Users reasonably assume connect(sparse); connect(dense) + weights=[sparse_w, dense_w] maps weights to those senders. The same graph + weights can therefore produce different hybrid scores.

Related: if a predecessor never runs (e.g. a ConditionalRouter branch is skipped), len(document_lists) < len(weights) and zip(..., strict=True) raises ValueError / PipelineRuntimeError.

To Reproduce

from haystack import Pipeline, Document, component
from haystack.components.joiners import DocumentJoiner

@component
class EmitDocs:
    def __init__(self, docs):
        self.docs = docs
    @component.output_types(documents=list[Document])
    def run(self):
        return {documents: self.docs}

p = Pipeline()
# alphabetical: dense < sparse  — opposite of connect order below
p.add_component(dense, EmitDocs([Document(content=shared, score=10.0)]))
p.add_component(sparse, EmitDocs([Document(content=shared, score=1.0)]))
p.add_component(joiner, DocumentJoiner(join_mode=merge, weights=[0.9, 0.1], sort_by_score=False))
p.connect(sparse, joiner)  # intended weight 0.9
p.connect(dense, joiner)   # intended weight 0.1

score = p.run({})[joiner][documents][0].score
print(score)
# actual today: 9.1  (dense*0.9 + sparse*0.1)
# expected if connect order: 1.9  (sparse*0.9 + dense*0.1)

Skipped-branch crash:

from haystack.components.routers import ConditionalRouter

# router -> branch_a / branch_b -> DocumentJoiner(weights=[0.5, 0.5])
# run with only branch_a selected -> zip length mismatch

Expected behavior

Weights follow connect() / InputSocket.senders order. Missing senders pad as empty lists so weighted merge/RRF does not crash.

Related

  • Closed discussion of alphabetical auto-variadic ordering: #10979 (auto-promoted list sockets; this issue is about explicit Variadic + DocumentJoiner weights)

👋 Hello there! This issue will be handled internally and isn't open for external contributions. If you'd like to contribute, please take a look at issues labeled contributions welcome or good first issue. We'd really appreciate it!

主要言語
Python
スター
27.2k
フォーク
3.5k
平均マージ
1日 18時間
マージ済み PR(30日)
254

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

deepset-ai/haystack のほかの issue

deepset-ai/haystack の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。