pywhyllm - v2#73
Open
grace-sng7 wants to merge 12 commits into
Open
Conversation
Update poetry.lock to match pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
LLM backend: moved from
guidancetoinstructorReplaced the
guidancelibrary withinstructor. The old design in v0.1 used blocking retry loops and parsed results from the LLM. The new design gets typed Pydantic objects directly from anyinstructor-wrapped async client.instructoralso enables compatibility with more LLMs.Model suggester class structure
ModelSuggester,IdentificationSuggester, andValidationSuggesterwere three separately-instantiated classes. They are now three private mixins (DiscoveryMixin,IdentificationMixin,ValidationMixin) that compose into a singleModelSuggester.IdentificationSuggester,ValidationSuggester, andSimpleIdentificationSuggesterare deleted as they are subsumed by theModelSuggester.API Call Reduction
The original
suggest_relationshipscalledsuggest_pairwise_relationshiponce per variable pair, per expert — sequentially. The newsuggest_graphsends all variables in a single prompt, and with multiple experts fires all calls in parallel via theasynciolibrary.Below illustrates the change in the number of API calls when using the
suggest_graphmethod.We further reduce the number of API calls needed in the entire workflow with the next change.
Return types: raw lists →
CausalGraphobjectsuggest_relationshipsreturned a raw list of(cause, effect)tuples with no metadata, and structural queries (parents,children,mediators,IVs) all required additional LLM calls.The new
CausalGraphobject stores per-edge vote counts, confidence scores, and per-expert reasonings, and answers all structural queries locally with zero LLM calls:parents_of,children_of,ancestors_of,descendants_ofmediators_of,instrumental_variables_fortop_edges,edge_data,reasoning_forplot()— built-in Graphviz DAG visualizationOther changes
min_confidencethreshold (default 0.5) — each expert provides a confidence level (from 0-1) for their reasoning. "Low-confidence" edges are dropped._prompts.py— all prompt strings extracted into 8 builder functions so that they aren't hardcoded into methodsinstructor-wrapped async client; switching providers requires only one lineTests
Added
test_causal_graph.py(33 tests),test_prompts.py(20 tests), expandedtest_model_suggester.py(25 async tests). Removed test files for deleted classes.Significant changes
---ModelSuggester(llm=guidance_model)→ModelSuggester(client=instructor_client, model="...")suggest_relationships(...)which previously returnedlist[tuple]now returns aCausalGraphsuggest_parents/children/mediators/ivsare now zero-LLM-call methods onCausalGraphIdentificationSuggesterandValidationSuggesterare removed; all functionality is onModelSuggester