Skip to content
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

Added Quran Eval & Simple Fact Model-Graded Definition #1511

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sakher
Copy link

@sakher sakher commented Apr 1, 2024

Thank you for contributing an eval! ♥️

🚨 Please make sure your PR follows these guidelines, failure to follow the guidelines below will result in the PR being closed automatically. Note that even if the criteria are met, that does not guarantee the PR will be merged nor GPT-4 access be granted. 🚨

PLEASE READ THIS:

In order for a PR to be merged, it must fail on GPT-4. We are aware that right now, users do not have access, so you will not be able to tell if the eval fails or not. Please run your eval with GPT-3.5-Turbo, but keep in mind as we run the eval, if GPT-4 gets higher than 90% on the eval, we will likely reject it since GPT-4 is already capable of completing the task.

We plan to roll out a way for users submitting evals to see the eval performance on GPT-4 soon. Stay tuned! Until then, you will not be able to see the eval performance on GPT-4. Starting April 10, the minimum eval count is 15 samples, we hope this makes it easier to create and contribute evals.

Also, please note that we're using Git LFS for storing the JSON files, so please make sure that you move the JSON file to Git LFS before submitting a PR. Details on how to use Git LFS are available here.

Eval details 📑

Eval name

Eval Set: quran-evals:
evals:
- guess_quran_verse_name
- guess_quran_verse_type
- guess_which_text_is_from_quran
- masked_quranic_text

Eval description

This evaluation assesses the comprehension and memorization capabilities of language models regarding Quranic texts. It features four distinct question types: Surah (Chapter) Identification, Meccan vs. Madinan Chapter type Revelation, Quranic Text Recognition (amongst non-Quranic text distractors), and Fill in the Blank. Each type is designed to test the models' abilities to recall, contextualize, and accurately interpret religious texts, providing insights into their potential use in educational and scholarly domains.

What makes this a useful eval?

This eval is valuable because it addresses a niche yet significant area of language model application: religious texts comprehension. It goes beyond general knowledge queries to test specific, detailed understanding and memorization of Quranic verses, challenging the models in a unique way that standard benchmarks may not. Additionally, this evaluation offers a perspective on the sensitivity and respectfulness and exactness required when handling religious texts, contributing to the development of more nuanced and culturally aware AI systems.

Here is a short report alongside the run results with different configurations:
https://sakher.notion.site/Using-OpenAI-Evals-for-Quranic-Text-Evaluation-06d8ca52d22449b4b7ac36f582c312e9

Criteria for a good eval ✅

Below are some of the criteria we look for in a good eval. In general, we are seeking cases where the model does not do a good job despite being capable of generating a good response (note that there are some things large language models cannot do, so those would not make good evals).

Your eval should be:

  • Thematically consistent: The eval should be thematically consistent. We'd like to see a number of prompts all demonstrating some particular failure mode. For example, we can create an eval on cases where the model fails to reason about the physical world.
  • Contains failures where a human can do the task, but either GPT-4 or GPT-3.5-Turbo could not.
  • Includes good signal around what is the right behavior. This means either a correct answer for Basic evals or the Fact Model-graded eval, or an exhaustive rubric for evaluating answers for the Criteria Model-graded eval.
  • Include at least 15 high-quality examples.

If there is anything else that makes your eval worth including, please document it below.

Unique eval value

The creation of the this eval represents a unique and crucial endeavor within the sphere of AI language understanding, particularly in relation to the profound significance of the Quran in the lives of hundreds of millions of Muslims worldwide. It's noteworthy to acknowledge that the Quran is not just a religious text; it embodies a tradition of memorization that spans centuries, where individuals, including children under the age of ten, commit its entirety to memory with remarkable precision. This practice underscores the importance of the Quran's literal preservation, where even the slightest deviation from its text is considered unacceptable.

Given this context, it's striking to observe when advanced AI models like those developed by OpenAI struggle with tasks that are second nature to millions, such as accurately identifying the chapter (Surah) a verse (Aya) belongs to or completing a partially provided verse. This isn't just a measure of the models' technical capabilities but a reflection on their understanding of the Quran's critical and sacrosanct nature to the global Muslim community.

Furthermore, this evaluation holds the potential to shed light on the models' proficiency with the Arabic language, particularly the nuanced and diacritic-rich script of the Quranic and other formal Arabic texts. It brings to the forefront the challenges existing tokenization techniques face with Arabic and other non-Latin languages, urging a reevaluation and improvement in how these languages are processed.

Incorporating this evaluation into OpenAI's framework is not merely a step towards enhancing a model's performance in the Arabic language; it's an initiative towards fostering respect, precision, and cultural sensitivity in AI's handling of religious texts. It is a call to recognize and honor the profound tradition of Quranic preservation through the lens of AI, ensuring that these models can approach the Quran with the accuracy and reverence it demands. This effort is not just about improving tokenization or understanding nuances in language—it's about bridging AI's capabilities with the deep-rooted values and traditions of millions of people worldwide.

I am also working on other evals related to Arabic language and other similar aspects.

Eval structure 🏗️

Your eval should

  • Check that your data is in evals/registry/data/{name}
  • Check that your YAML is registered at evals/registry/evals/{name}.yaml
  • Ensure you have the right to use the data you submit via this eval

(For now, we will only be approving evals that use one of the existing eval classes. You may still write custom eval classes for your own cases, and we may consider merging them in the future.)

Final checklist 👀

Submission agreement

By contributing to Evals, you are agreeing to make your evaluation logic and data under the same MIT license as this repository. You must have adequate rights to upload any data used in an Eval. OpenAI reserves the right to use this data in future service improvements to our product. Contributions to OpenAI Evals will be subject to our usual Usage Policies (https://platform.openai.com/docs/usage-policies).

  • I agree that my submission will be made available under an MIT license and complies with OpenAI's usage policies.

Email address validation

If your submission is accepted, we will be granting GPT-4 access to a limited number of contributors. Access will be given to the email address associated with the commits on the merged pull request.

  • I acknowledge that GPT-4 access will only be granted, if applicable, to the email address used for my merged pull request.

Limited availability acknowledgment

We know that you might be excited to contribute to OpenAI's mission, help improve our models, and gain access to GPT-4. However, due to the requirements mentioned above and the high volume of submissions, we will not be able to accept all submissions and thus not grant everyone who opens a PR GPT-4 access. We know this is disappointing, but we hope to set the right expectation before you open this PR.

  • I understand that opening a PR, even if it meets the requirements above, does not guarantee the PR will be merged nor GPT-4 access be granted.

Submit eval

  • I have filled out all required fields of this form
  • I have used Git LFS for the Eval JSON data
  • (Ignore if not submitting code) I have run pip install pre-commit; pre-commit install and have verified that mypy, black, isort, autoflake and ruff are running when I commit and push

Failure to fill out all required fields will result in the PR being closed.

Eval JSON data

Since we are using Git LFS, we are asking eval submitters to add in as many Eval Samples (at least 5) from their contribution here:

View evals in JSON

Eval

{"input": [{"role": "system", "content": "Identify the Surah (in Arabic) of the following Quranic text: النَّارِ ذَاتِ الْوَقُودِ"}, {"role": "user", "content": "Please provide the answer, and ONLY the answer without any extra commentary"}], "ideal": "البروج"}
{"input": [{"role": "system", "content": "حدد اسم السورة للنص القرآني التالي: وَلَهَدَيْنَاهُمْ صِرَاطًا مُسْتَقِيمًا"}, {"role": "user", "content": "يرجى تقديم الإجابة. وفقط الإجابة دون أي تعليق إضافي"}], "ideal": "النساء"}
{"input": [{"role": "system", "content": "Determine if the Surah of the following Quranic aya text is meccan or madinan: النَّارِ ذَاتِ الْوَقُودِ answer only with either 'meccan' or 'madinan'"}, {"role": "user", "content": "Please provide the answer, and ONLY the answer without any extra commentary"}], "ideal": "meccan"}
{"input": [{"role": "system", "content": "حدد إذا كانت السورة للنص القرآني التالي مكية أو مدنية: يَتَنَازَعُونَ فِيهَا كَأْسًا لَا لَغْوٌ فِيهَا وَلَا تَأْثِيمٌ أجب فقط بـ 'مكية' أو 'مدنية'"}, {"role": "user", "content": "يرجى تقديم الإجابة. وفقط الإجابة دون أي تعليق إضافي"}], "ideal": "مكية"}
{"input": [{"role": "system", "content": "Which of the following is a text from the Quran? A. مَنْ يَدْعُو بِقَلْبٍ خَاشِعٍ فِي ظُلَمَاتِ اللَّيلِ، يَجِدُ نُورَ الْإِجَابَةِ فِي فَجْرِ الْأَمَلِ; B. الْحَيَاةُ دَرْبٌ مَمْلُوءٌ بِالابْتِلاءِ، وَلَكِنَّ مَعَ كُلِّ عُسْرٍ يُسْرًا لِمَنْ يَصْبِرُ; C. النَّارِ ذَاتِ الْوَقُودِ; D. وَمَن يَتَوَكَّلْ عَلى اللهِ فَقَدْ اهتَدى إلى طَريقٍ مُبين, please answer with the letter of the correct option (A, B, C, D) only"}, {"role": "user", "content": "Please provide the answer by selecting the correct letter (A, B, C, or D) without any extra commentary"}], "ideal": "C"}
{"input": [{"role": "system", "content": "أي من التالي هو نص من القرآن؟ A. وَمِن دُعاءِ اللَّيلِ فَهُوَ قُربانٌ لِربِّكُم، وَنُورٌ يَقطَعُ ظُلمةَ الشَّكِ; B. اعْلَمُوا أَنَّ فِي الصَّبْرِ عَلَى الْمُصَائِبِ تَزْكِيَةٌ لِلنُّفُوسِ، وَقُرْبٌ مِنَ الْخَالِقِ; C. كَأَنَّهُمْ يَوْمَ يَرَوْنَهَا لَمْ يَلْبَثُوا إِلَّا عَشِيَّةً أَوْ ضُحَاهَا; D. وَيَبْعَثُ اللَّهُ الرِّيَاحَ بُشْرَىً قَبْلَ رَحْمَتِهِ، مَاءً يُحْيِي الأَرْضَ بَعْدَ مَوْتِهَا, يرجى الإجابة بحرف الخيار الصحيح (A, B, C, D) فقط"}, {"role": "user", "content": "يرجى تقديم الإجابة. وفقط الإجابة دون أي تعليق إضافي"}], "ideal": "C"}
{"input": [{"role": "system", "content": "Fill in the blank of the following Quranic text: ((________ ذَاتِ الْوَقُودِ)) to complete the full verse. This text is from Surah البروج (Chapter 85, Verse 5)..  The answer may be one or more words."}, {"role": "user", "content": "Please provide the answer, and ONLY the answer without any extra commentary"}], "ideal": "النَّارِ"}
{"input": [{"role": "system", "content": "Fill in the blank of the following Quranic text: ((وَمَا نَقَمُوا مِنْهُمْ إِلَّا ________)) to complete the full verse..  The answer may be one or more words."}, {"role": "user", "content": "Please provide the answer, and ONLY the answer without any extra commentary"}], "ideal": "أَنْ يُؤْمِنُوا بِاللَّهِ الْعَزِيزِ الْحَمِيدِ"}
{"input": [{"role": "system", "content": "املأ الفراغ في النص القرآني التالي: ((يَتَنَازَعُونَ ________)) لإتمام الآية كاملة. هذا النص القرآني من سورة الطور (السورة 52، الآية 23).. قد تكون الإجابة عبارة عن كلمة واحدة أو أكثر."}, {"role": "user", "content": "يرجى تقديم الإجابة. وفقط الإجابة دون أي تعليق إضافي"}], "ideal": "فِيهَا كَأْسًا لَا لَغْوٌ فِيهَا وَلَا تَأْثِيمٌ"}
{"input": [{"role": "system", "content": "املأ الفراغ في النص القرآني التالي: ((________ عَذَابَ رَبِّكَ لَوَاقِعٌ)) لإتمام الآية كاملة.. قد تكون الإجابة عبارة عن كلمة واحدة أو أكثر."}, {"role": "user", "content": "يرجى تقديم الإجابة. وفقط الإجابة دون أي تعليق إضافي"}], "ideal": "إِنَّ"}

@sakher sakher changed the title Added Quran Eval Added Quran Eval & Simple Fact Model-Graded Definition Apr 1, 2024
@sakher
Copy link
Author

sakher commented Apr 11, 2024

I've made the code for generating this eval public to aid with reviewing this PR.

https://github.com/sakher/open-ai-quran-eval-generation

Thanks in advance!

@sakher
Copy link
Author

sakher commented Apr 15, 2024

@andrew-openai
@etr2460
@katyhshi

Is there anything I can do to help aiding the review of this PR? I appreciate that it is from a domain and a language that can be challenging to review.

I made the repo for the generation public which contains some hopefully useful comments - and happy to do more.

Copy link
Collaborator

@usama-openai usama-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. This PR looks good. I would like to request some changes.

  1. guess_quran_verse_name and guess_quran_verse_type evals should be renamed to guess_quran_surah_name and guess_quran_surah_type because the eval is about the name and type of surah and not the verses.

  2. The "ModelGraded" evaluation method isn't suitable for this kind of prompt. That method is used when there is a subjective answer to a prompt. For these evals, the "Match" or "Include" evaluation method should be used.

  3. When using the "Match" or "Include" evaluation method, the ideal answer should be a list of possible answers, i.e., the ideal answer should contain the correct answer with all possible variations, like "ideal": ["سباء","سَبَاء"]. Also, add instructions to provide an answer without airaab to avoid any mismatch between the model-provided answer and the ideal answer.

  4. It would be much appreciated if you put the dataset generation script and resource in the evals/registry/data/quran_eval directory.

We would love to review the PR again after the suggested changes.

@sakher sakher changed the title Added Quran Eval & Simple Fact Model-Graded Definition Support GPT-4o, Added Quran Eval & Simple Fact Model-Graded Definition May 17, 2024
@sakher
Copy link
Author

sakher commented May 17, 2024

  1. The "ModelGraded" evaluation method isn't suitable for this kind of prompt. That method is used when there is a subjective answer to a prompt. For these evals, the "Match" or "Include" evaluation method should be used.
  2. When using the "Match" or "Include" evaluation method, the ideal answer should be a list of possible answers, i.e., the ideal answer should contain the correct answer with all possible variations, like "ideal": ["سباء","سَبَاء"]. Also, add instructions to provide an answer without airaab to avoid any mismatch between the model-provided answer and the ideal answer.

I agree that ModelGraded is an overkill for guess_surah_name and guess_surah_type, as well as guess which text is quranic and that match or include would give very similar results, much cheaper. But the as for the latest eval (guess masked text), I have done many tests, the model guided is much better in spotting mistakes that can seem simple (e.g. differences in diacritics that severely change the meaning). Also, you can't really include add all possible variations given the model can output more or less diacritics while keeping the meaning valid. I will make the changes and test and report the results.

EDIT 1:
After looking into the guess_sourah_name - the variations are too many to capture in the list of potential ideal answers, and I think keeping model-guided is warranted, for example, we need to account for the following cases:

  • With / without diacritics
  • With or without the definite article "ال" at the beginning.
  • Different transliterations or spellings.
  • With or without spaces between the words.
  • With or without punctuation marks.
  • and many others

I will change the guess_sourah_type and guess_which_text_is_from_quran to include but will keep the others as model-guided, I hope you don't mind.

@sakher
Copy link
Author

sakher commented May 17, 2024

@usama-openai - I have done all of the changes and updated the documentation about the results (including the raw results and log files) here:
https://sakher.notion.site/Using-OpenAI-Evals-for-Quranic-Text-Evaluation-06d8ca52d22449b4b7ac36f582c312e9

As mentioned earlier, I have changed the evaluation method only for 2 of the 4 evals to use 'includes' instead of 'model-guided'. I hope this works!

P.S. I applied for some credits via the research program earlier but didn't get any response, this is largely self-funded. I would appreciate if you can help with this! Also, I am very keen to help improving evaluation and training on the Arabic language; if you guys have any valuable evals in mind, please let me know (I have a few I am looking into already).

And sorry for bundling a few changes in one PR - I am more than happy to separate if you prefer.

@sakher sakher requested a review from usama-openai May 17, 2024 08:48
Copy link
Collaborator

@usama-openai usama-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks in good shape now. Kindly keep only evaluation-related changes in this PR and create a new PR for GPT-4o-related changes.

@sakher sakher changed the title Support GPT-4o, Added Quran Eval & Simple Fact Model-Graded Definition Added Quran Eval & Simple Fact Model-Graded Definition Jun 20, 2024
@sakher
Copy link
Author

sakher commented Jun 20, 2024

The PR looks in good shape now. Kindly keep only evaluation-related changes in this PR and create a new PR for GPT-4o-related changes.

Thanks @usama-openai - I removed all code changes related to adding gpt-4o (my changes have been incorporated into another PR #1530 which I reviewed and happy with).

Kindly look into this once you have a second.

@sakher sakher requested a review from usama-openai June 20, 2024 14:15
@sakher
Copy link
Author

sakher commented Jun 20, 2024

I have a few evals in mind to add related to Arabic language - but wanted to ensure that they would be valuable and likely accepted before putting the effort - is there a way to communicate with the evals team at OpenAI (e.g. chat or email)?
Happy to provide my email here if needed.

usama-openai
usama-openai previously approved these changes Jun 22, 2024
Copy link
Collaborator

@usama-openai usama-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks in good shape now. I'm approving this PR.

@sakher
Copy link
Author

sakher commented Jun 24, 2024

@usama-openai - the unit tests fail on this PR as well as on main (not sure why they are being skipped for some other recent PRs!).
I created an issue and a PR to resolve all unit test failures:
#1537

Please merge the fix, once done, I will rebase into this PR and re-run the unit tests which hopefully would make this eval ready to merge.

@sakher sakher requested a review from usama-openai June 24, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants