2. Motivation
Generative AI technologies will revolutionize many aspects of our lives
How will they change our experience of Islam?
Ansari is an experiment to explore that question
The intention: help people practice Islam
Wanted to share my experiences building it to inform and stimulate further
discussion
3. Plan
- The LLM Revolution
- What is Ansari?
- Ansari Architecture
- What is Ansari capable of?
- How do people use Ansari?
- Qualitative feedback
- Ongoing work
- Validation
- Additional features
- Conclusion
4. The Large Language Model Revolution
- Large Language Models
- Use a new AI deep learning architecture called Transformers
- Trained on trillions of words in multiple languages
- Have emergent properties that we don’t understand
- Have shown amazingly strong performance on real world problems
- Passed admission exams in medical, legal and business exams
- Scores 710 out of 800 on SAT high school exams (better than 93% of high schoolers)
- Quantum leap from current natural language processing approaches
- Summarizing
- Question answering
- Sentiment analysis
- Machine Translation
5. What is Ansari?
Ansari is an LLM-based Islamic assistant that helps answers questions about
Islam
https://ansari.chat (Demo)
6. Chat based large language models
- Conversation presented as a set of messages.
- 3 roles:
- System prompt: Defines personality of the assistant
- User prompt: A question the user gives
- Assistant response: Previous responses the assistant has given
- Can use external tools to augment the construction of answers
- What an LLM does:
- Given the history of the conversation so far and any information from tools, what is the next
message to add to the conversation?
8. System Prompt excerpt (the personality of Ansari)
You are a helpful assistant. Your name is Ansari. You help Muslims become
stronger in their faith …
Respond to questions with information drawn from the Hadith and Qur'an and
opinions from respected classical and modern scholars in the Sunni tradition …
Be gentle, forbearing and non-judgemental …
Be particularly careful about something is obligatory or prohibited …
9. Example walkthrough
User: Are corals mentioned in the Qur’an?
Ansari: search_quran(“coral”)
Kalemat API:
Returns list of 10 verses that are considered (not all relevant)
Ansari:
Yes, corals are mentioned in the Qur'an. Here are the relevant verses:
Ayah: 55:22
Arabic: ُﺎنَﺟَْرﻣْﻟٱ َ
و ُُؤﻟ ْ
ﱡؤﻠٱﻟ َﺎﻣُﮭْﻧِﻣ ُجُرَْﺧﯾ
English: Out of both ˹waters˺ come forth pearls and coral.
Ayah: 55:58
Arabic: ُﺎنَﺟَْرﻣْﻟٱ َ
و ُُوتﻗَﺎﯾْﻟٱ ُنﱠﮭﱠﻧَﺄَﻛ
English: Those ˹maidens˺ will be ˹as elegant˺ as rubies and coral.
10. What can Ansari do?
Complete list with examples: walee.dk/ansarican
- Answer Qur’an and Hadith questions
- Tell you what dua to read
- Answer basic fiqh questions
- Discuss different opinions on controversial topics
- Consoling/Removing doubts
- Can help with Arabic morphology
- Is multilingual
- Can generate ideas or trivia questions
- Can write a khatira/khutbah
11. Current state of Ansari
- First released in June 2023, with continuous improvement
- Word of mouth only
- Experiment period: 31 July 2023 - Nov 12 2023
- Days: 103
- Total threads: 3032 (30/day)
- Total messages: 7822 (76/day)
12. What questions do people ask?
- Extracted 2500 unique, short questions
- Used an LLM to put them into categories
13.
14. Other?
- Summarize Islam for me
- ﺑﺎﻹﻧﺟﻠﯾزي ﻣﺳﺗﺣﺎﺿﺔ
- Do you know black seed oil?
- Meaning of dreaming of a lion
- similarities between aboriginal religion and islam
- How to explain Islam to a 5 year old
16. Feedback (Positive)
“I used Ansari whilst at Hajj. Although there were a lot of Mashaikh around, it was
a good tool to get initial information that assisted in more informed conversations
and validation with the mashaikh. Alhamdulillah, it proved to be useful to a few of
us around.”
20. IERA Assessment
Positive:
… this is definitely headed in the right direction mashallah.
1. It is great that the questions, where applicable, begin with the Quran and hadith to explain.
Negative:
2. When geared to non-muslim audiences, the views of the scholars' additional explanations are less relevant
3. When the question relates to a command in the quran or hadith … I would be looking for a statement around "Ultimately Muslims do
________ because they believe Allah is the One true God and his Prophet Muhammad is his Messenger. Therefore whatever they
command, are things Muslims follow. Do you believe in God?"
22. Feedback (Negative)
“When I studied with ‘ulema, before I was granted an ijaaza, they didn’t just check
my knowledge, they checked my adab, my character. Who is giving Ansari its
ijaaza?”
“Ansari makes mistakes – how can you release this publicly?”
23. Current area: Evaluation of Ansari’s correctness
- Most recent work
- 323 Islamic multiple choice questions provided by Dr. Muhsin Rashwan
- Early results on first 200 questions: 78% correctness
- Challenge is not everyone agrees on answers.
- Examples of mistakes:
24. ﻣﺳﯾﺣﯾﺔ؟ ﻣن اﻟزواج ﺣﻛم ﻣﺎ
Ansari said “”ﯾﺟوز, but the “correct” answer was “اﻷﺣﯾﺎن ﺑﻌض ﻓﻲ ”ﯾﺟوز
Ansari’s explanation:
The Qur'an in Ayah 5:5 clearly states that marriage to chaste women of the People
of the Book (Christians and Jews) is permissible as long as the dowry is given in
wedlock and the relationship is not illicit. This is further supported by the teachings
of scholars such as Imam Shafiee and Imam Abu Hanifah who also permit such
marriages.
25. ?واﻟﻔﺿﺔ اﻟذھب أواﻧﻲ ﻓﻲ اﻷﻛل ﺣﻛم ﻣﺎ
Ansari said “ﻣطﻠﻘﺎ ”ﺣرام, but the “correct” answer was “ﻣطﻠﻘﺎ ”ﺣﻼل
Ansari’s explanation:
The Prophet Muhammad ()ﷺ explicitly prohibited the use of gold and silver
utensils for eating and drinking in several authentic Hadiths. For instance, in Sahih
Bukhari (Chapter: 74, Hadith: 5633), the Prophet ()ﷺ said, 'Do not drink in gold
or silver utensils, and do not wear clothes of silk or Dibaj, for these things are for
them (unbelievers) in this world and for you in the Hereafter.'
Islam QA concurs!
26. What’s next for Ansari?
- More validation with high quality Islamic exams (working with Darul Qaasim)
- Question: Can you give an AI Assistant an Ijaaza?
- More tools:
- In addition to Qur’an + Hadith, add more info sources (tafseer, etc).
- Add prayer times
- More personalization:
- Choosing the madhab or the scholars
- Ansari-as-a-Service
- Modified versions of Ansari for particular topics (e.g. Zakaat or Da’wah)
- Or for audiences (e.g. for children in Islamic schools)
27. Concluding remarks
- Ansari has seen a very positive response from the community
- Questions remain, however, about how to validate it to make sure it’s not
making mistakes
- Right now, the greatest need is for the construction of an evaluation dataset
for Islamic Assistants
- Users seem to really like it
- This is just the beginning!
28. Special Thanks
- Allah (SWT) for giving me this opportunity
- Amin Ahmad (Founder of Vectara) for outstanding technical advice
- Dr Mohammad Khair for help with obtaining first evaluation test data
- Hossam Hassan for provision of Kalemat API for Quran and Hadith search
- Saifeldeen Hadid, Iman Sadreddin, Mohammed Zeki Khedher for
identifying errors
- Shahed Amanullah, Ibrahim Housheya and Amjad BaniMatter and the
team at EndeavorPal for frontend/mobile development.