Improving the Exodus Experience with AI

Joseph Liu
9 min readMar 16, 2024

Background:

Misunderstandings happen all the time in our relationships. There’s no reason why we can’t misunderstand the Bible as well; a book designed for us to have a relationship with God.

To remedy this, we have scholars that examine the Bible verse-by-verse and analyze the context, meaning and background behind the verse to fully understand what was God’s intention by putting the verse in there. I have to be thankful to my Professor Carmen Imes who opened my eyes to see how different Exodus can look like when interpreted correctly. (Go buy her book!: https://www.amazon.com/Bearing-Gods-Name-Sinai-Matters/dp/0830852697 ).

Solution:

An idea sparked within me when I saw how Microsoft integrated AI into their browser which allowed a user to highlight over certain parts of the passage and then the AI can use Bing Search to analyze the context behind the message.

This seems really good at first glance but it becomes apparent how the AI falls short in giving any substantial or meaningful description about the verse.

Consider a user who wanted to know more if the 4th Commandment indicated false swearing (I swear upon the Lord…) or vain swearing (..D*mn!). Highlighting the verse gives us the following results.

The Copilot AI returns:

The commandment states: “You shall not take the name of the Lord your God in vain.” This divine instruction emphasizes reverence and respect for God’s name. Those who misuse or treat it lightly will not be held guiltless. It serves as a reminder to honor the sacred and approach the divine with awe and humility.

Summary: Show reverence for God’s name and avoid using it in vain.

Well that doesn’t tell us much. In contrast let’s look at the commentary’s analysis of the verse.

7 “You shall not take the name of the LORD your God in vain, The third word. The Hebrew here is ambiguous and can be taken to mean either forbidding false swearing only, or to include profane or vain swearing. If we look 1371 to the words of Jesus in Matthew 5, it appears that false swearing is what is being referred to here. He says — “Again you have heard that it was said to those of old, ‘You shall not swear falsely, but shall perform your oaths to the Lord.’” Matthew 5:33 The word for “vain” in Hebrew is shav and is used here for the first time in the Bible. It means falsely, lying, vain, etc. The intent of this command is that one should never invoke the name of the Lord in a false manner. And should they presume to do so…

Unfortunately these commentaries can be long like really long, like

source: I googled “Exodus Commentary PDF” and downloaded the biggest boi

2738 pages long. Their wording may find inexperienced readers tired and lethargic after reading them. Navigating these commentaries can be difficult for the average user. Furthermore certain commentaries stretch for many pages leaving users tired and exhausted once they finish reading it.

A proposed solution involves developing an AI that can analyze highlighted verses and review accompanying commentaries to provide insights based on the information fed into it. This system could encompass multiple books and sources, ensuring that the analysis is both reliable and rich, backed by expert scholars. By clarifying ambiguities and misunderstandings in the Bible, this tool could enhance believers’ spiritual journeys, bringing them closer to God.

Code

For an In-depth tutorial behind the method of implementation check out my other blogs!

import bs4
from langchain import hub
from langchain_community.document_loaders import WebBaseLoader
from langchain_community.vectorstores import Chroma
from langchain_core.output_parsers import StrOutputParser
from langchain_core.runnables import RunnablePassthrough, RunnableParallel
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain_text_splitters import RecursiveCharacterTextSplitter

import getpass
import dotenv
import os

dotenv.load_dotenv()

os.environ["Open_AI_API_Key"] = getpass.getpass()

from langchain_community.document_loaders import PyPDFLoader

loader = PyPDFLoader("Problem of Pain CS Lewis.pdf")
loader = loader.load_and_split()

text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
splits = text_splitter.split_documents(loader.load())
vectorstore = Chroma.from_documents(documents=splits, embedding=OpenAIEmbeddings())

# Retrieve and generate using the relevant snippets of the blog.
retriever = vectorstore.as_retriever()
prompt = hub.pull("rlm/rag-prompt")
llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0)

def format_docs(docs):
return "\n\n".join(doc.page_content for doc in docs)


rag_chain_from_docs = (
RunnablePassthrough.assign(context=(lambda x: format_docs(x["context"])))
| prompt
| llm
| StrOutputParser()
)

rag_chain_with_source = RunnableParallel(
{"context": retriever, "question": RunnablePassthrough()}
).assign(answer=rag_chain_from_docs)

Testing it with the question:

“In the 4th commandment, does God mean false swearing or vain swearing?”

rag_chain_with_source.invoke("In the 4th commandment does God mean false swearing or vain swearing?")

Results in :

‘In the 4th commandment, God means false swearing, as indicated by Jesus in Matthew 5:33. The Hebrew word used for “vain” in this context means falsely, lying, or vain. The commandment is against invoking the name of the Lord falsely.’

The AI also has the ability to cite its sources as well as the book page, book title as well. The sources are in the Appendix of this Page.

Conclusion and Limitations:

In conclusion, the challenge of making in-depth analysis and commentary accessible to the general public could be addressed by implementing AI in a biblical context. Such a tool could help Christians minimize confusion when reading the Bible and facilitate a deeper understanding of God’s intentions.

By leveraging insights from expert scholars, theologians, and professors, this AI-driven approach can ensure accuracy and clarity in interpreting biblical texts.

One of the main limitations of the AI is that it requires context for it to work. If we give it the exact same litmus test of the verse with no context as; similar to Co-Pilot — we can see the results.

Question:

“You shall not take the name of the Lord your God in vain, for the Lord will not hold him guiltless who takes his name in vain.”

rag_chain_with_source.invoke("You shall not take the name of the Lord your God in vain, for the Lord will not hold him guiltless who takes his name in vain.")

Answer:

“You shall not take the name of the Lord your God in vain, for the Lord will not hold him guiltless who takes His name in vain.” This commandment warns against using the Lord\’s name in a disrespectful or insincere manner. It emphasizes the importance of honoring and respecting the name of God.”

We can see that it lacks the depth the previous answer produced. The lack of context can be fixed by adding a fixed prompt such as, “Analyze the verse using the commentary provided: {insert verse}“ can produce better results.

Question:

Analyze the verse using the commentary provided: You shall not take the name of the Lord your God in vain, for the Lord will not hold him guiltless who takes his name in vain.”

Answer:
The commentary provided explains that the verse prohibits reviling God or cursing a ruler of the people, as both derive their authority from God. This emphasizes the importance of honoring God’s name and those appointed by Him. The verse serves as a reminder to respect the authority and sovereignty of the Lord.

We can see that this produces a much better answer to the analysis of the verse, yet lacks the capacity to answer the question we wanted it to answer — About the difference between false swearing and vain swear — due to the lack of context. Continued adjustment and playing with the model might be helpful.

Limitations: Bible Versions:

One of the main advantages of having a verse-by-verse commentary is that it simplifies the process for the AI to identify relevant sections of the book as it searches for similarities to the question. When a verse is included in the question, the AI can focus specifically on the commentary surrounding that verse, due to the high similarity between the question and the verse.

However, using different versions of the Bible could diminish this advantage, potentially leading to less accurate results. A straightforward solution is to standardize all verses to the appropriate versions, which is technically feasible and not overly challenging.

Appendix

{‘context’: [Document(page_content=’1371 \n to the words of Jesus in Matthew 5, it appears that false swearing is what is being \nreferred to here. He says — \n \n”Again you have heard that it was sa id to those of old, \’You shall not swear \nfalsely, but shall perform your oaths to the Lord.\’” Matthew 5:33 \n \nThe word for “vain” in Hebrew is shav and is used here for the first time in the \nBible. It means falsely, lying, vain, etc. The intent of this comma nd is that one \nshould never invoke the name of the Lord in a false manner. And should they \npresume to do so… \n \n7 (con\’t) for the LORD will not hold him guiltless who takes His name in vain. \n \nThis doesn\’t mean that there will be immediate punishment on the offender. \nRather, it is something that may come in this life as the perjured man is found out \nand punished, or it may be in the day of God\’s judgment in the future. Malachi \nshows us this — \n \n”\’And I will come near you for judgment; \nI will be a swift witnes s \nAgainst sorcerers, \nAgainst adulterers,’, metadata={‘page’: 1370, ‘source’: ‘exodus.pdf’}),

Document(page_content=’1371 \n to the words of Jesus in Matthew 5, it appears that false swearing is what is being \nreferred to here. He says — \n \n”Again you have heard that it was sa id to those of old, \’You shall not swear \nfalsely, but shall perform your oaths to the Lord.\’” Matthew 5:33 \n \nThe word for “vain” in Hebrew is shav and is used here for the first time in the \nBible. It means falsely, lying, vain, etc. The intent of this comma nd is that one \nshould never invoke the name of the Lord in a false manner. And should they \npresume to do so… \n \n7 (con\’t) for the LORD will not hold him guiltless who takes His name in vain. \n \nThis doesn\’t mean that there will be immediate punishment on the offender. \nRather, it is something that may come in this life as the perjured man is found out \nand punished, or it may be in the day of God\’s judgment in the future. Malachi \nshows us this — \n \n”\’And I will come near you for judgment; \nI will be a swift witnes s \nAgainst sorcerers, \nAgainst adulterers,’, metadata={‘page’: 1370, ‘source’: ‘exodus.pdf’}),

Document(page_content=’command, the entire congregation violated it — \n \n”And Aaron said to them, \’Break off the golden earrings which are in the \nears of your wives, your sons, and your daughters, and bring them to me.\’ \n3 So all the people broke off t he golden earrings which were in their ears, \nand brought them to Aaron. 4 And he received the gold from their hand, \nand he fashioned it with an engraving tool, and made a molded calf. \nThen they said, \’This is your god, O Israel, that brought you out of the land \nof Egypt!\’” Exodus 32:2 -4 \n \nConcerning this second command, something else was needed. The second word \nonly condemns, it cannot save. \n \n7 “You shall not take the name of the LORD your God in vain, \n \nThe third word. The Hebrew here is ambiguous and can be taken to mean either \nforbidding false swearing only, or to include profane or vain swearing. If we look’, metadata={‘page’: 1369, ‘source’: ‘exodus.pdf’}),

Document(page_content=’command, the entire congregation violated it — \n \n”And Aaron said to them, \’Break off the golden earrings which are in the \nears of your wives, your sons, and your daughters, and bring them to me.\’ \n3 So all the people broke off t he golden earrings which were in their ears, \nand brought them to Aaron. 4 And he received the gold from their hand, \nand he fashioned it with an engraving tool, and made a molded calf. \nThen they said, \’This is your god, O Israel, that brought you out of the land \nof Egypt!\’” Exodus 32:2 -4 \n \nConcerning this second command, something else was needed. The second word \nonly condemns, it cannot save. \n \n7 “You shall not take the name of the LORD your God in vain, \n \nThe third word. The Hebrew here is ambiguous and can be taken to mean either \nforbidding false swearing only, or to include profane or vain swearing. If we look’, metadata={‘page’: 1369, ‘source’: ‘exodus.pdf’})],

--

--

Joseph Liu
0 Followers

Dream Catcher, Dream Catcher, Tell me What You See