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

Abierto
#12,646 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

  • #12647 de @coder058 — cerrado sin fusionar

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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!

Lenguaje dominante
Python
Estrellas
27.2k
Forks
3.5k
Merge medio
1 d 18 h
PR fusionados (30 d)
254

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de deepset-ai/haystack

Todos los issues de deepset-ai/haystack

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.