-
Notifications
You must be signed in to change notification settings - Fork 20.3k
CPAL #6255
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
CPAL #6255
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Question: Is it feasible for this PR of a proposed new CPAL chain to get into the library? I suspect there is a chance it's not because of the following reasons.
I am checking with you before I start working on the tests, and Jupyter notebook doc. |
|
This is really cool. I'll take a closer look at the code later tonight, but I absolutely think this is something we'd like to include in the library. If it's too complicated, then we could at least put in the ps I'm a big fan of the DoWhy library also btw. |
|
super interesting. yeah lets include in experimental for now |
|
@borisdev is attempting to deploy a commit to the LangChain Team on Vercel. A member of the Team first needs to authorize it. |
|
@borisdev this is awesome and looks pretty good to me! |

Causal program-aided language (CPAL) chain
Motivation
This builds on the recent Program-aided Language (PAL) approach to stop LLM hallucination. The problem with the PAL approach is that it hallucinates on a math problem with a nested chain of dependence. The innovation here is that this new CPAL approach includes causal structure to fix hallucination.
For example, using the below word problem, PAL answers with 5, and CPAL answers with 13.
The CPAL chain represents the causal structure of the above narrative as a causal graph or DAG, which it can also plot, as shown below.
.
The two major sections below are:
Also see this jupyter notebook doc.
1. Technical overview
CPAL versus PAL
Like PAL, CPAL intends to reduce large language model (LLM) hallucination.
The CPAL chain is different from the PAL chain for a couple of reasons.
PAL's generated python code is wrong. It hallucinates when complexity increases.
CPAL's generated python code is correct.
Based on the comments below, CPAL's intended location in the library is
experimental/chains/cpaland PAL's location ischains/pal.CPAL vs Graph QA
Both the CPAL chain and the Graph QA chain extract entity-action-entity relations into a DAG.
The CPAL chain is different from the Graph QA chain for a few reasons.
Evaluation
Preliminary evaluation on simple math word problems shows that this CPAL chain generates less hallucination than the PAL chain on answering questions about a causal narrative. Two examples are in this jupyter notebook doc.
2. Future application
"Describe as Narrative, Test as Code"
The thesis here is that the Describe as Narrative, Test as Code approach allows you to represent a causal mental model both as code and as a narrative, giving you the best of both worlds.
Why describe a causal mental mode as a narrative?
The narrative form is quick. At a consensus building meeting, people use narratives to persuade others of their causal mental model, aka. plan. You can share, version control and index a narrative.
Why test a causal mental model as a code?
Code is testable, complex narratives are not. Though fast, narratives are problematic as their complexity increases. The problem is LLMs and humans are prone to hallucination when predicting the outcomes of a narrative. The cost of building a consensus around the validity of a narrative outcome grows as its narrative complexity increases. Code does not require tribal knowledge or social power to validate.
Code is composable, complex narratives are not. The answer of one CPAL chain can be the hypothetical conditions of another CPAL Chain. For stochastic simulations, a composable plan can be integrated with the DoWhy library. Lastly, for the futuristic folk, a composable plan as code allows ordinary community folk to design a plan that can be integrated with a blockchain for funding.
An explanation of a dependency planning application is here.
Twitter handle: @boris_dev