-
Notifications
You must be signed in to change notification settings - Fork 26
Creating augmented suggester #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
grace-sng7
wants to merge
20
commits into
main
Choose a base branch
from
creating_augmented_suggester
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a82e872
Created new augmented_model_suggester and corresponding utils.
grace-sng7 63e6d82
Updated dependencies according to augmented_model_suggester and corre…
grace-sng7 b81e676
Updated LLM query prompt.
grace-sng7 2af6350
Minor fixes after testing AugmentedModelSuggester.
grace-sng7 e349bf5
Edited CauseNet search function.
grace-sng7 633d76d
Updated README.md to include augmented_model_suggester
grace-sng7 a474e5d
Update README.md
grace-sng7 d31fc79
Merge pull request #53 from grace-sng7/creating_augmented_suggester
grace-sng7 6b71deb
Update README.md
grace-sng7 d763517
Added augmented model suggester examples notebook
grace-sng7 e2f57e4
Merge pull request #55 from grace-sng7/creating_augmented_suggester
grace-sng7 072adc4
Uploaded augmented model suggester examples notebook again.
grace-sng7 8d82bd9
Merge branch 'py-why:creating_augmented_suggester' into creating_augm…
grace-sng7 fd17322
Merge pull request #56 from grace-sng7/creating_augmented_suggester
grace-sng7 05d9aa9
Set to ignore notebook testing for augmented model suggester examples
grace-sng7 0d1c2b5
Merge pull request #57 from grace-sng7/augmented_suggester
grace-sng7 00b61a2
Updated augmented_model_suggester_examples notebooks, docstrings, and…
grace-sng7 83a968f
Merge pull request #58 from grace-sng7/augmented_suggester
grace-sng7 2c6c7c2
Updated citations
grace-sng7 bfde305
Merge pull request #59 from grace-sng7/augmented_suggester
grace-sng7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
156 changes: 156 additions & 0 deletions
156
docs/notebooks/augmented_model_suggester_examples.ipynb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
{ | ||
"nbformat": 4, | ||
"nbformat_minor": 0, | ||
"metadata": { | ||
"colab": { | ||
"provenance": [] | ||
}, | ||
"kernelspec": { | ||
"name": "python3", | ||
"display_name": "Python 3" | ||
}, | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"pip install dotenv" | ||
], | ||
"metadata": { | ||
"id": "cmZerbMu6Uk4" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"id": "EulKv3Km4nMa" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from dotenv import load_dotenv\n", | ||
"import os\n", | ||
"\n", | ||
"load_dotenv()\n", | ||
"\n", | ||
"os.environ[\"OPENAI_API_KEY\"] = '' # specify your key here" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"pip install pywhyllm" | ||
], | ||
"metadata": { | ||
"collapsed": true, | ||
"id": "83sxVcP97xlH" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"Here we introduce the AugmentedModelSuggester class. Creating an instance of it enables the chosen LLM to utilize Retrieval Augmented Generation (RAG) to determine causality. It currently does this by searching the CauseNet dataset for a relevant causal pair and augmenting the LLM with the corresponding evidence/information stored in the dataset.\n", | ||
"\n", | ||
"CauseNet is a large-scale knowledge base of causal relations extracted from the web, created by Heindorf et al. (2020). CauseNet is available at [causenet.org](https://causenet.org) and is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0)." | ||
], | ||
"metadata": { | ||
"id": "DjYECuX84vbN" | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"from pywhyllm.suggesters.augmented_model_suggester import AugmentedModelSuggester\n", | ||
"\n", | ||
"model = AugmentedModelSuggester('gpt-4')" | ||
], | ||
"metadata": { | ||
"id": "VdfEKuDLEYcU" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"AugmentedModelSuggester can suggest the pairwise relationship given two variables. If a relevant causal pair is found in CauseNet, the LLM is augmented with the aforementioned information in CauseNet. If not found, by default, the LLM will rely on its own knowledge." | ||
], | ||
"metadata": { | ||
"id": "dES0LwHV57eX" | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"result = model.suggest_pairwise_relationship(\"smoking\", \"lung cancer\")" | ||
], | ||
"metadata": { | ||
"id": "D85ec6Pk5JzA" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"result" | ||
], | ||
"metadata": { | ||
"id": "W3bFehXh5SQl" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"result = model.suggest_pairwise_relationship(\"income\", \"exercise level\")" | ||
], | ||
"metadata": { | ||
"id": "odFkp921hQsX" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"result" | ||
], | ||
"metadata": { | ||
"id": "ZIeStj9OwIPe" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"result = model.suggest_pairwise_relationship(\"flooding\", \"rain\")" | ||
], | ||
"metadata": { | ||
"id": "Fm5XCFrRwKsV" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"result" | ||
], | ||
"metadata": { | ||
"id": "HDo098ICwzi7" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
} | ||
] | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notebook makes sense.
Can you add some description/text to the notebook so that readers can understand: