SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.23972 · 2026

Grounding Arabic LLMs in the Doha Historical Dictionary: Retrieval-Augmented Understanding of Qur'an and Hadith

Somaya Eltanbouly, Samer Rashwani

arXiv · PDF · Open in the Atlas

Code that ran

11 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 9 failures of our instrument; 0 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2603.23972.json · badge: /api/ran/2603.23972.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
somayaeltanbouly/Doha-Dictionary-RAG canonical (classifier label)
classifier basis: census
11 ran · 0 no recorded run
FunctionStatusWhere it lives
build_contrastive_pairs Ran
ran; our contract draft was wrong, not the code
somayaeltanbouly/Doha-Dictionary-RAG/src/data_processing/build_ce_training_data.py
code served (permissive licence) · get_code("f9caf0de1f184ebd")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import random

# Create a small sample DataFrame with question-document pairs
data = {
    'question': [
        'What is machine learning?',
        'What is machine learning?',
        'How does deep learning work?',
        'How does deep learning work?',
        'What is Python?',
    ],
    'text': [
        'Machine learning is a subset of AI that learns from data.',
        'ML uses algorithms to improve performance.',
        'Deep learning uses neural networks with multiple layers.',
        'Neural networks are inspired by biological neurons.',
        'Python is a programming language.',
    ],
    'query_id': [
        'q1',
        'q1',
        'q2',
        'q2',
        'q3',
    ],
    'doc_id': [
        'd1',
        'd2',
        'd3',
        'd4',
        'd5',
    ],
}

df = pd.DataFrame(data)

ARGS = {
    'df': df,
    'question_col': 'question',
    'text_col': 'text',
    'query_id_col': 'query_id',
    'doc_id_col': 'doc_id',
    'num_negatives': 1,
    'random_state': 42,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_config_value Ran
ran, honoured the contract we drafted
somayaeltanbouly/Doha-Dictionary-RAG/src/config_loader.py
code served (permissive licence) · get_code("dda08563ab818db1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import Any, Optional

torch.manual_seed(0)

# Construct a nested configuration dictionary
config = {
    "retrieval": {
        "top_k": 10,
        "method": "hybrid",
        "threshold": 0.5
    },
    "model": {
        "name": "bert-base",
        "hidden_size": 768,
        "num_layers": 12
    },
    "training": {
        "batch_size": 32,
        "learning_rate": 1e-4,
        "epochs": 3
    }
}

# Test case 1: Valid nested key path
key_path_1 = "retrieval.top_k"

# Test case 2: Nested key with multiple levels
key_path_2 = "model.hidden_size"

# Test case 3: Non-existent key path with default
key_path_3 = "retrieval.missing_key"

# Default value to use when key is not found
default_value = 5

# Create ARGS dictionary with all parameters
ARGS = {
    "config": config,
    "key_path": key_path_1,
    "default": default_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_config Ran
ran; our contract draft was wrong, not the code
somayaeltanbouly/Doha-Dictionary-RAG/src/config_loader.py
code served (permissive licence) · get_code("4e1e515cd98addc1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
from pathlib import Path
import yaml

# Create a temporary directory and config file for testing
temp_dir = tempfile.mkdtemp()
config_path = Path(temp_dir) / 'config.yaml'

# Write a sample config file
config_data = {
    'model': 'transformer',
    'learning_rate': 0.001,
    'batch_size': 32,
    'epochs': 10,
    'layers': [64, 128, 256]
}

with open(config_path, 'w', encoding='utf-8') as f:
    yaml.dump(config_data, f)

# Test case 1: explicit config_path
ARGS = {
    'config_path': str(config_path)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
yaml — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
nonempty Ran
ran, violated the contract we drafted
somayaeltanbouly/Doha-Dictionary-RAG/src/data_processing/data_utils.py
code served (permissive licence) · get_code("416417941c9ed033")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function 'nonempty' takes a single parameter 'value'
# It checks if value is None, if it's NA (via pandas), and if the string representation is non-blank
# We need to test various cases to ensure the function works correctly

ARGS = {
    "value": "hello"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_args Ran
ran; our contract draft was wrong, not the code
somayaeltanbouly/Doha-Dictionary-RAG/src/data_processing/build_ce_training_data.py
code served (permissive licence) · get_code("918f2e9c2265278b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Namespace. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import argparse

ARGS = {
    'argv': [
        '--qd-path', 'data/questions_data/QD_data/QD_full_data.csv',
        '--output', 'data/questions_data/QD_data/QD_contrastive_data.csv',
        '--n-source', '5000',
        '--num-negatives', '1',
        '--random-state', '42'
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_args Ran
ran; our contract draft was wrong, not the code
somayaeltanbouly/Doha-Dictionary-RAG/src/data_processing/build_classification_data.py
code served (permissive licence) · get_code("1260b9cd3c59081e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Namespace. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import argparse

ARGS = {
    'argv': [
        '--corpus', 'data/retrieval_corpus/processed/DHDA_filtered_AR.csv',
        '--inscriptions', 'data/retrieval_corpus/processed/DHDA_inscriptions_data.csv',
        '--output', 'data/questions_data/classification_data/classification_data.csv',
        '--n-per-type', '1000',
        '--random-state', '42'
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_args Ran
ran; our contract draft was wrong, not the code
somayaeltanbouly/Doha-Dictionary-RAG/src/data_processing/build_qa_pairs.py
code served (permissive licence) · get_code("5980505de32a7a96")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Namespace. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import argparse

ARGS = {
    'argv': [
        '--corpus', 'data/retrieval_corpus/processed/DHDA_filtered_AR.csv',
        '--output-dir', 'data/questions_data/QA_data'
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_args Ran
ran; our contract draft was wrong, not the code
somayaeltanbouly/Doha-Dictionary-RAG/src/data_processing/build_retrieval_corpus.py
code served (permissive licence) · get_code("753003f43fa84bb3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Namespace. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import argparse

# This function only parses command-line arguments
# It doesn't actually use any of the parsed values internally
# So we just need to pass argv=None to use defaults, or pass a list of strings

ARGS = {
    'argv': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_args Ran
ran; our contract draft was wrong, not the code
somayaeltanbouly/Doha-Dictionary-RAG/src/evaluation/judge.py
code served (permissive licence) · get_code("dab51bf0bad97e29")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Namespace. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import argparse

ARGS = {
    'argv': [
        '--input', 'output/model_answers.csv',
        '--output', 'judging/judging_results.csv',
        '--api-delay', '1.5'
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
strip_tashkeel Ran
ran; our contract draft was wrong, not the code
somayaeltanbouly/Doha-Dictionary-RAG/src/data_processing/data_utils.py
code served (permissive licence) · get_code("f83d431e173e9b4a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

_TASHKEEL_RE = re.compile('[\\u064B-\\u065F\\u0610-\\u061A\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED]')

def strip_tashkeel(text: str) -> str:
    """Remove all Arabic diacritical marks from *text*."""
    return _TASHKEEL_RE.sub('', text)


# Create test arguments
# The function takes a single parameter: text (str)
# It removes Arabic diacritical marks (tashkeel) from the text

# Test with Arabic text containing diacritical marks
# Unicode range for Arabic diacritics:
# \u064B-\u065F (Fathatan to Shadda)
# \u0610-\u061A (Arabic Sign Sallallahou)
# \u06D6-\u06DC (Small High Ligature Sad with Lam with Alef)
# \u06DF-\u06E4 (Small High Rounded Zero to Small High Madda)
# \u06E7-\u06E8 (Small High Yeh to Small High Noon)
# \u06EA-\u06ED (Empty Centre Low Stop to Arabic End of Ayah)

arabic_text_with_diacritics = "مَرْحَبًا"  # "marhaba" (hello) with diacritics
arabic_text_clean = "مرحبا"  # same word without diacritics

ARGS = {
    "text": arabic_text_with_diacritics
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
word_type Ran
ran; our contract draft was wrong, not the code
somayaeltanbouly/Doha-Dictionary-RAG/src/data_processing/data_utils.py
code served (permissive licence) · get_code("77d3d504b0a8f69b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

# Analyze the function:
# - Takes a single parameter 'text' of type str
# - Checks if ' ' (space) is in str(text).strip()
# - Returns 'عبارة' if space found, 'كلمة' otherwise

# Test case 1: multi-word text (contains space)
text_multi_word = "hello world"

# Test case 2: single-word text (no space)
text_single_word = "hello"

ARGS = {
    "text": text_multi_word
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large language models (LLMs) have achieved remarkable progress in many language tasks, yet they continue to struggle with complex historical and religious Arabic texts such as the Qur'an and Hadith. To address this limitation, we develop a retrieval-augmented generation (RAG) framework grounded in diachronic lexicographic knowledge. Unlike prior RAG systems that rely on general-purpose corpora, our approach retrieves evidence from the Doha Historical Dictionary of Arabic (DHDA), a large-scale resource documenting the historical development of Arabic vocabulary. The proposed pipeline combines hybrid retrieval with an intent-based routing mechanism to provide LLMs with precise, contextually relevant historical information. Our experiments show that this approach improves the accuracy of Arabic-native LLMs, including Fanar and ALLaM, to over 85%, substantially reducing the performance gap with Gemini, a proprietary large-scale model. Gemini also serves as an LLM-asa-judge system for automatic evaluation in our experiments. The automated judgments were verified through human evaluation, demonstrating high agreement (κ = 0.87). An error analysis further highlights key linguistic challenges, including diacritics and compound expressions. These findings demonstrate the value of integrating diachronic lexicographic resources into retrieval-augmented generation frameworks to enhance Arabic language understanding, particularly for historical and religious texts. The code and resources are publicly available at: https://github.com/somayaeltanbouly/Doha-Dictionary-RAG.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2603.23972")
get_code_for_paper("2603.23972")
have("2603.23972")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2603.23972.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2603.23972.svg)](https://syntology.ai/paper/2603.23972)

Connect an agent — have() is free.