mostafaelaraby/Arabic-Sentence-Segmentation-Dual-View

AraSegmenter is an open source Arabic sentence segmentation system developed for the AraSeg 2026 Open Track. It identifies sentence boundaries in Arabic documents, including text without punctuation or paragraph breaks.

Python

0

2 commits

updated Sep 15, 2026

See the code

README

Arabic Sentence Segmentation with Dual Views

Code accompanying MostafaElAraby at the AraSeg Shared Task 2026: Combining Lexical and Punctuation Evidence across Aligned Text Views.

Paper | Notebook | Open in Colab

Two CAMeLBERT-MSA ensembles predict sentence boundaries from the punctuation-free NoPnx-NP view and its parallel punctuated NP view. A learned rule combines their decisions with punctuation aligned to the target words.

EvaluationPrecisionRecallF1
Development80.6691.0184.61
Official blind test81.8789.5084.88

Scores are document-macro percentages reported in the paper; aggregate blind scores were supplied by the organizers. Blind inputs and per-document run reports are not distributed in this repository.

Reproduce in Colab

  1. Open the notebook above and select Runtime > Change runtime type > GPU.
  2. Put the organizer-provided blind_set.zip in MyDrive/AraSeg/train_only/inputs/. It must contain blind_nopnx-np.tsv and blind_np.tsv, each with doc_id and tokens columns. Each tokens value is a serialized list of strings.
  3. Run all cells. Approve the Google Drive mount and adjust DRIVE_ROOT or the archive/member names in the configuration cell if needed.

The notebook clones this public repository without a GitHub token, installs the runtime, and loads/caches the official Hugging Face train and development splits. It trains five fold models and three final seed models per view, or reuses a complete compatible model set already saved in Drive. First-time training requires a sustained GPU session and space for 16 model checkpoints. CPU tests use tiny models; full CAMeLBERT training on CPU is impractical.

Outputs persist in MyDrive/AraSeg/train_only/:

data/                         cached train/dev documents
models/                       fold and final models, frozen decoders and rule
  training_audit.json          training IDs, fingerprints, settings and provenance
  inference_manifest.json     model paths and frozen inference settings
inference_runs/<timestamp>/
  prediction.csv              Document ID,Prediction; one bit per target word
  prediction.zip              CodaBench archive, CSV member named prediction
  inference_report.json       input hashes, runtime and development metrics
  *.npz                       per-seed and ensemble probabilities

Set DOWNLOAD_PREDICTION_ZIP=True for a browser download. Set RUN_DEV_EVALUATION=False to skip development scoring. A later run reuses complete saved models; FORCE_RETRAIN=True replaces them. An interrupted first training run restarts fitting if the complete model set was not saved.

Blind inputs and trained weights are not distributed here. Without the blind archive, run through development evaluation to reproduce the public-data workflow. The notebook follows the paper's method; new GPU training can produce different weights, selected rules, and scores. The recorded inference runtime was Python 3.13, PyTorch 2.11.0, Transformers 4.48.3, and Datasets 3.6.0. The notebook pins Transformers and Datasets and retains Colab's installed PyTorch/CUDA runtime.

Training protocol

All fitting and selection use the 174 official training documents: five-fold document-level cross-validation chooses the epoch count; pooled out-of-fold predictions calibrate each decoder and the 12-pattern fusion rule. Three final models per view use seeds 42, 1337, 2024 and train on the full training split. Development is evaluation-only; the public test split is unused.

The configuration uses 512-subtoken windows, stride 64, final-subtoken labels, mean overlap logits, up to five epochs, batch size 16 with two accumulation steps, learning rate 3e-5, and unweighted cross entropy. The full system requires both parallel views. Development falls back to the target classifier for unaligned documents; blind inference stops unless all IDs and words align.

Repository

notebooks/train_and_infer_colab.ipynb   single training and inference entry point
configs/camelbert_official.yaml        paper training recipe
src/araseg/                           training, alignment, fusion and scoring
tests/                                offline regression and tiny CPU tests
paper/main.pdf                        accompanying paper

Run tests

Use Python 3.10+ and run the following commands from the repository root (the directory containing pyproject.toml). A GPU, Google Drive, trained checkpoints, and the AraSeg dataset are not required.

Install the package and test dependencies once, preferably in a virtual environment:

python -m pip install -e ".[dev]"

Run the full suite:

python -m pytest

The current suite contains 70 tests. A successful run ends with 70 passed and exits with code 0. Dependency installation needs internet access; the tests run offline using synthetic documents, locally built tokenizers, and tiny CPU models. They cover training and model reuse, token alignment, overlapping windows, ensembling, fusion, scoring, and CSV/ZIP output. Notebook tests exercise its orchestration with simulated model calls; separate CPU tests run real training.

For a focused check or more detail:

python -m pytest tests/test_notebooks.py
python -m pytest tests/test_pipeline_tiny.py
python -m pytest -v

These checks validate the implementation; reproducing the paper's scores requires the full Colab training and evaluation workflow above.

Data and citation

Please cite the accompanying paper when using this implementation. Citation metadata is in CITATION.cff. Code is licensed under MIT; the linked datasets and pretrained model retain their respective licenses.

mostafaelaraby/Arabic-Sentence-Segmentation-Dual-View

AraSegmenter is an open source Arabic sentence segmentation system developed for the AraSeg 2026 Open Track. It identifies sentence boundaries in Arabic documents, including text without punctuation or paragraph breaks.

Python

0

2 commits

updated Sep 15, 2026

See the code

README

Arabic Sentence Segmentation with Dual Views

Code accompanying MostafaElAraby at the AraSeg Shared Task 2026: Combining Lexical and Punctuation Evidence across Aligned Text Views.

Paper | Notebook | Open in Colab

Two CAMeLBERT-MSA ensembles predict sentence boundaries from the punctuation-free NoPnx-NP view and its parallel punctuated NP view. A learned rule combines their decisions with punctuation aligned to the target words.

EvaluationPrecisionRecallF1
Development80.6691.0184.61
Official blind test81.8789.5084.88

Scores are document-macro percentages reported in the paper; aggregate blind scores were supplied by the organizers. Blind inputs and per-document run reports are not distributed in this repository.

Reproduce in Colab

  1. Open the notebook above and select Runtime > Change runtime type > GPU.
  2. Put the organizer-provided blind_set.zip in MyDrive/AraSeg/train_only/inputs/. It must contain blind_nopnx-np.tsv and blind_np.tsv, each with doc_id and tokens columns. Each tokens value is a serialized list of strings.
  3. Run all cells. Approve the Google Drive mount and adjust DRIVE_ROOT or the archive/member names in the configuration cell if needed.

The notebook clones this public repository without a GitHub token, installs the runtime, and loads/caches the official Hugging Face train and development splits. It trains five fold models and three final seed models per view, or reuses a complete compatible model set already saved in Drive. First-time training requires a sustained GPU session and space for 16 model checkpoints. CPU tests use tiny models; full CAMeLBERT training on CPU is impractical.

Outputs persist in MyDrive/AraSeg/train_only/:

data/                         cached train/dev documents
models/                       fold and final models, frozen decoders and rule
  training_audit.json          training IDs, fingerprints, settings and provenance
  inference_manifest.json     model paths and frozen inference settings
inference_runs/<timestamp>/
  prediction.csv              Document ID,Prediction; one bit per target word
  prediction.zip              CodaBench archive, CSV member named prediction
  inference_report.json       input hashes, runtime and development metrics
  *.npz                       per-seed and ensemble probabilities

Set DOWNLOAD_PREDICTION_ZIP=True for a browser download. Set RUN_DEV_EVALUATION=False to skip development scoring. A later run reuses complete saved models; FORCE_RETRAIN=True replaces them. An interrupted first training run restarts fitting if the complete model set was not saved.

Blind inputs and trained weights are not distributed here. Without the blind archive, run through development evaluation to reproduce the public-data workflow. The notebook follows the paper's method; new GPU training can produce different weights, selected rules, and scores. The recorded inference runtime was Python 3.13, PyTorch 2.11.0, Transformers 4.48.3, and Datasets 3.6.0. The notebook pins Transformers and Datasets and retains Colab's installed PyTorch/CUDA runtime.

Training protocol

All fitting and selection use the 174 official training documents: five-fold document-level cross-validation chooses the epoch count; pooled out-of-fold predictions calibrate each decoder and the 12-pattern fusion rule. Three final models per view use seeds 42, 1337, 2024 and train on the full training split. Development is evaluation-only; the public test split is unused.

The configuration uses 512-subtoken windows, stride 64, final-subtoken labels, mean overlap logits, up to five epochs, batch size 16 with two accumulation steps, learning rate 3e-5, and unweighted cross entropy. The full system requires both parallel views. Development falls back to the target classifier for unaligned documents; blind inference stops unless all IDs and words align.

Repository

notebooks/train_and_infer_colab.ipynb   single training and inference entry point
configs/camelbert_official.yaml        paper training recipe
src/araseg/                           training, alignment, fusion and scoring
tests/                                offline regression and tiny CPU tests
paper/main.pdf                        accompanying paper

Run tests

Use Python 3.10+ and run the following commands from the repository root (the directory containing pyproject.toml). A GPU, Google Drive, trained checkpoints, and the AraSeg dataset are not required.

Install the package and test dependencies once, preferably in a virtual environment:

python -m pip install -e ".[dev]"

Run the full suite:

python -m pytest

The current suite contains 70 tests. A successful run ends with 70 passed and exits with code 0. Dependency installation needs internet access; the tests run offline using synthetic documents, locally built tokenizers, and tiny CPU models. They cover training and model reuse, token alignment, overlapping windows, ensembling, fusion, scoring, and CSV/ZIP output. Notebook tests exercise its orchestration with simulated model calls; separate CPU tests run real training.

For a focused check or more detail:

python -m pytest tests/test_notebooks.py
python -m pytest tests/test_pipeline_tiny.py
python -m pytest -v

These checks validate the implementation; reproducing the paper's scores requires the full Colab training and evaluation workflow above.

Data and citation

Please cite the accompanying paper when using this implementation. Citation metadata is in CITATION.cff. Code is licensed under MIT; the linked datasets and pretrained model retain their respective licenses.