Sibawayh on GitHub العربية

How Sibawayh is tested

كيف نختبر «سيبويه»؟

Sibawayh is a skill that makes an AI agent write correct Arabic and check it before answering. This page describes how we measure whether it works, and what the measurements do not show.

The request

اشرح مفهوم الـ caching في تطبيقات الويب لمدير غير تقني، وبيّن لماذا يجعل الموقع أسرع.

Response A without the skill

الـ Caching (التخزين المؤقت) يعني أن نحتفظ بنسخة جاهزة من المعلومات التي يكثر طلبها، فنقدّمها مباشرة بدلاً من تحضيرها من جديد في كل مرة.

بدون Caching: كلما طلب زبون قهوة، يذهب الموظف إلى المخزن ويطحن البُن ويغلي الماء.

الـ Caching يحفظ الصفحة الجاهزة بعد أول مرة، فيحصل عليها كل زائر بعده فوراً.

Marked: an English word used in place of the Arabic term, three times in this excerpt. The judge counts each as a register error.

Response B with Sibawayh

التخزين المؤقت (Caching) هو أن يحتفظ النظام بنسخة جاهزة من المعلومات التي يكثر طلبها، فيقدّمها مباشرة بدلًا من أن يعيد إعدادها من الصفر في كل مرة.

دون تخزين مؤقت: كلما فتح زائر صفحة، يطلبها متصفحه من الخادم (Server)، فيبحث الخادم في قاعدة البيانات ويجمع المحتوى ويبني الصفحة ثم يرسلها.

مع التخزين المؤقت: يبني الخادم الصفحة مرة واحدة ويحفظ نسخة منها، ثم يرسل هذه النسخة الجاهزة إلى الزوار التاليين فورًا.

Nothing marked. The English term appears once, in parentheses after the Arabic one.

This is what the judge sees: one request and two unnamed answers. It does not know which one was written with the skill.

Excerpts from two real answers in the 23 November run of the test. The judge counted errors in both before anyone looked up which was which.

Four tests, four questions

No single test covers a writing skill. The blind comparison measures the whole skill on realistic requests. The other three test parts of it that can be checked without a judge.

TestQuestionWho decidesResult
Blind comparisonDoes an agent make fewer Arabic errors with the skill than without it?An AI judge from a different model family, three times2.26 → 0.07 errors per 100 words, 97% fewer; no over-corrections
Over-correction checkDoes the checker flag Arabic that is already correct?Every flag reviewed by hand0 false errors in 191 error flags on 806,509 words
RecallWhat share of real errors does the checker catch?Human annotators of two public corpora52% of all errors in student essays, 41% in news comments
Trigger testDoes the skill load for Arabic requests, and stay out of English ones?Automatic20 of 20

The checker also has 163 unit tests, one or more for every rule and every bug fixed.

The blind comparison

The same agent answers the same requests twice, once with the skill and once without. A judge that cannot tell the two apart counts the errors in each answer.

  1. 100 requests

    20 each of emails, social posts, documentation, technical explanations and translations into Arabic. 68 are written in Arabic and 32 in English asking for Arabic. They are in evals/prompts.tsv.

    The first 50 were in use while the skill was being developed. The second 50 were written afterwards, and the skill was not changed after it answered them. The results below report the two halves separately.

  2. Two answers to each

    Claude Code answers every request in a fresh, empty folder. In the skill run the folder holds a copy of the skill; in the baseline run it holds nothing. Both runs have the same tools and ignore the user's own settings, so an installed copy of the skill cannot leak into the baseline.

  3. Blind pairs

    Each request and its two answers go into one file as Response A and Response B, in random order. The list of which is which stays outside the folder the judge can read.

  4. A judge from another model family

    GPT, run through Codex with read-only access, counts the errors in each response in five categories and says which response reads as more correct and natural. Claude does not grade its own output.

    All 100 pairs are judged three times, each time in a new random A/B order, because the judge's counts vary from one reading to the next.

  5. Unblind and check the bar

    The counts are mapped back to baseline and skill and divided by the number of words. The skill passes only if it meets all three conditions: no over-corrections, at most half the baseline's errors per 100 words, and no category worse than the baseline.

What the judge counts

The judge's full instructions are in evals/ai_judge.md. It is told not to count an error when it is unsure.

Results of the blind comparison

Run on 25 November 2026 with release 0.4.0 of the skill; the answers without the skill are the same as in the 23 November run. In the three judgings the skill's answers had 96% to 98% fewer errors per 100 words (97% on average), no over-corrections, and no category worse than the baseline, so the bar was met each time.

Errors per 100 words, in each of the three judgings

100 pairs; 19,181 words without the skill and 22,344 with it.

  • Without the skill
  • With Sibawayh
First judging
2.18
0.05
Second judging
2.25
0.07
Third judging
2.34
0.09
By category, mean of the three judgings
Errors per 100 wordsWithoutWith
Register1.500.01
Translationese0.390.05
Formatting0.240.00
Grammar0.130.01
Spelling0.010.00
Total2.260.07

About two thirds of the baseline's errors are register errors, and most of those are English technical terms written as if they were Arabic words, as in the example at the top of this page. The skill's largest effect is therefore on technical writing. Its remaining errors are mostly translationese: 11 or 12 in 100 answers, depending on the judging.

By kind of request, mean of the three judgings
Errors per 100 wordsWithoutWith
Technical explanations4.410.05
Documentation1.740.11
Social posts1.720.06
Translations0.930.13
Emails0.310.01
Requests the skill was developed with, and requests it had never seen
Errors per 100 wordsWithoutWithChange
First 50 requests2.150.01−99%
50 new requests2.370.12−95%

The skill was tuned on the first 50 requests, where it now makes almost no errors. The 50 new requests are the fairer measure, and there the result is 95% fewer errors, the same as in the 23 November run.

Asked which response reads as more correct and natural, the judge chose the skill's in 92 or 93 of the 100 pairs and the baseline's in 3 or 4. The rest were ties.

Full results: every request, both answers and the judge's counts.

The 23 November run, with release 0.3.0, gave 2.22 → 0.10 errors per 100 words (96% fewer). The answers are generated once per run and vary from run to run, so a difference of this size between two runs is not evidence that one release is better.

Classical register: a first trial

Release 0.4.0 adds a classical register (فصحى التراث) that the skill uses only when the request asks for it. We tried it on 20 requests: sermons, letters, a maqama, a counsel and a literary debate. The judge preferred the skill's answer to the answer without the skill in 17 to 19 of the 20 pairs, and to the answer of the previous release in 12 of 20. In a separate check it found no classical wording in the skill's answers to everyday requests.

This is a small trial, judged by an AI model, and it is separate from the comparison above. Method, figures and limits: evals/classical.md.

Full report and earlier runs: evals/full_eval.md.

The over-correction check

The skill's first rule is never to flag correct Arabic. To measure that, the checker runs on Arabic that has already been edited: 100 featured articles from Arabic Wikipedia, 806,509 words. Every error it reports is read in context by hand when a rule is added or changed.

Half of the articles were used to tune the rules. The other half were held out and used for no change.

SetWordsError flagsFalse
50 articles used for tuning416,602880
50 held-out articles389,9071030

The flags were real errors that featured articles still contain, such as إثنين، الإتجاه، شئ، يتسائل، خمسة عشرة سفينة.

Two weaker kinds of finding did less well. In the first review, automatic fixes made 1 wrong change in 278: a Persian letter cited on its own in a table of alphabets, which the rule now leaves alone. Warnings only ask the agent to look again at the context, and some of them are wrong, mostly on proper names and cited letters (the surname حتي, the wrestler بيغ شو).

Details: evals/corpus_check.md.

Recall: how many real errors the checker catches

A checker that never flags anything would pass the test above, so recall is measured twice.

Against people's corrections

Two public corpora in which annotators corrected every word by hand: ZAEBUC, essays by first-year university students (9,932 words), and QALB-2014, comments on news articles by native speakers (50,309 words). Recall is the share of the words they corrected that a checker finding covers.

Error typeStudent essaysNews comments
و written apart from its word98%86%
Hamza68%59%
ة and ه37%40%
ى and ي14%40%
All error types52%41%

"All error types" includes grammar, word choice and punctuation choices that a script cannot judge. The skill leaves those to the agent's own review checklist, so the checker's recall is not the skill's recall. When the checker does catch a single-word error, its suggestion matches the annotators' correction 80% of the time in the essays and 91% in the comments.

Against injected errors

A script takes clean lines from the held-out Wikipedia articles, puts one known error into each (for example ، becomes ,, or أ becomes ا), and checks whether the checker finds it. 200 sites per error type.

Error injectedCaught
Space before ،, Persian letters, tatweel100%
Mixed digit systems99%
هاذا، لاكن، ذالك98%
لم، لن، أن before a verb that keeps its ن97%
Latin comma in Arabic text89%
ي written ى72%
Missing hamza65%
ة written ه54%
ى written ي10%

The low rows are low on purpose. مدرسه is wrong but عليه is right, and إلي and علي are real words. Telling them apart needs grammar, so the checker flags only the shapes that are wrong in every context and the agent's checklist covers the rest.

Details: evals/benchmarks.md. The two corpora are not redistributed; their licences do not allow it.

The trigger test

A skill that does not load does nothing. Twenty requests check that it loads when Arabic is involved and stays out otherwise:

  • 14 requests in Arabic or for Arabic output, including summarise, rewrite and proofread. All 14 loaded the skill.
  • 4 requests for English text or code only. None loaded it.
  • 2 requests for Egyptian and Gulf dialect. Both loaded it. For dialect the skill checks formatting only and must leave the dialect words alone; that part is read by hand.

The requests are in evals/triggers.tsv.

What these tests do not show

  • No native reader has scored the answers yet. AI models are only moderately reliable at judging Arabic grammar. The judge is from a different model family and works blind, but the size of the effect needs a human round to confirm. The answers and scores are public so that anyone can do it.
  • Each request was answered once per side. Answers vary from run to run, and that variation is not measured. One bad answer moves the total by about 0.05 errors per 100 words.
  • The judge is noisy. The same baseline answers score differently in each judging, so the change is compared within a judging and averaged over three.
  • One agent. All answers come from Claude Code. Other agents can load the skill but have not been measured.
  • Wikipedia is edited, not proofread, and the articles are the first 100 featured articles in category order, not a random sample.

Run it yourself

Everything is in the repository and uses only the Python standard library. Generating answers needs the claude command line tool and uses your own usage.

git clone https://github.com/anasAsh/Sibawayh && cd Sibawayh

python3 -m unittest discover -s tests -t .       # unit tests
python3 evals/run_triggers.py                    # trigger test

python3 evals/generate.py --mode baseline        # answers without the skill
python3 evals/generate.py --mode skill           # answers with it
python3 evals/pair.py --seed 1 judge key.csv     # blind A/B pairs; keep key.csv away from the judge
python3 evals/judge_report.py scores.csv key.csv # unblind, totals, pass or fail

python3 evals/fetch_wiki.py --limit 50           # over-correction check
python3 evals/corpus_check.py evals/corpus/wiki
python3 evals/inject.py evals/corpus/wiki        # recall with injected errors

Read all 100 requests, both answers to each and the judge's counts on the full results page. Every answer, blind key and score file from the runs on this page is in evals/results/. If you read Arabic natively and want to score a set of pairs, open an issue.