r/LangChain • u/RhubarbFlat6247 • 16h ago
Discussion In my pipeline, the model doesn't choose which numbers to count: the code tries each combination, then rejection and acceptance gates before any result.
The problem I started with: I planted a three-step calculation in a test case, with the numbers coming from three different sources. A general agent with complete arithmetic tools couldn't find it. He knew how to multiply, but he didn't know which numbers belonged to which group!
The usual method is for the model to write the equation and for a tool to calculate it. But this way, the model still chooses the inputs, and that's where the problem lies.
So my pipeline ended up like this:
- extract => two models extract every quantity => unit => denominator => scope (structured output).
- reconcile => keep a value only if both extractions agree, or a verbatim source quote settles it.
- enumerate => code tries every combination of 2-4 quantities whose units produce a decision unit.
- compute => unit library (pint), never the model.
- reject => 6 deterministic checks on the numbers
- accept => 6 gates in order; one failure drops the candidate
- explain => the model only writes up what survived; "no discovery" is the default
In a prototype: 230 candidate accounts, two remained, with the one planted in between. The second was disguised, passing because a number in it had no denominator. Hence the rejection gates: recalculation, an impossible number due to its lack of a denominator, a quantity without a denominator or unit, discrepancies between the extractors, mixing ranges (weekly with monthly), and the fragility of the conclusion with a 5% change.
Then the admission gates in order: new to the file, then new to the field, then non-intuitive, then influential, then case-specific, then change the decision.
The assessment method was recorded in advance before any case was built: 100 cases, of which 30 were empty and 20 were misleading, with a false positive limit of 5%: https://doi.org/10.5281/zenodo.24506889
Questions I haven't thought of yet;
- How could you extract units and denominators with organized outputs? This is my weakest point.
- Has anyone thought of building a layer to verify the deterministic outputs after the agent's outputs? What could you put in it?
- What happens when the combinations get too large? I have a maximum of 4 quantities, and I'm considering trimming by units before counting.