Asif EjazAI engineering / interactive demo← All demos
Fine tuned AraBERT on CPU. No large language model involved.

The key terms of an Arabic company contract, pulled out in seconds

Paste a Saudi company formation contract and get a term sheet back: who the parties are, the capital, the purpose, who manages it, the fiscal year and more, each linked to the exact words in the contract it came from.

20
kinds of term it looks for
…
of words labelled correctly on contracts it never saw
…
exact passage F1 on whole contracts, up from …
Try it

Load a sample contract, or paste your own

The samples are full length contracts with invented names and numbers, built from the standard Saudi templates. Nothing you paste is stored.

Samples
Loading a sample contract.
What I found when I reopened this project

The model had only ever read the first page

This began as client work in 2024. The reported score looked fine. Measuring it again on whole contracts told a different story, and fixing the cause is what turned it into something usable.

0.84

The score on record

Training cut every contract off at 512 word pieces, roughly the first 280 words, and the test did the same. So the 0.84 only ever described the opening of each contract, where six of the twenty term types appear.

…

The same model on whole contracts

Read all the way through, it kept seeing parties and company names in clauses about liquidation and audits, because it had never been shown what the rest of a contract looks like. For fourteen of the twenty term types it did not get a single word right.

…

After retraining on overlapping windows

Same data, same base model, same 15 test contracts. Retraining on windows that cover every word took the exact passage score to …. Keeping one passage per term, since each term appears once in these contracts, took it to the figure above. That same rule applied to the old model gives ….

An exact passage only counts when it starts and ends on precisely the right words, which is strict for a clause a hundred words long. Counted word by word, the retrained model puts … of words in the right place, against … before. The table shows both views for every term on the unseen contracts.

Under the hood

Small enough to run beside production workloads

Model

AraBERT with a token classifier on top

Each word gets one of 41 labels: the start or the continuation of one of 20 term types, or nothing. Only the top four encoder layers and the classifier were retrained; the lower eight layers were frozen and their outputs cached, which let the whole retraining run on a laptop processor in under an hour and a half.

Long contracts

Overlapping windows

The model reads 512 word pieces at a time and a contract runs to several thousand. Windows overlap by a third, and where two windows disagree about a word, the one with more context on both sides wins.

Serving

ONNX on CPU

The trained model is exported to ONNX and runs without a graphics card, a little under a second per window on a laptop processor. I also built an 8 bit version: four times smaller and twice as fast, but it lost five points of word accuracy, so the full precision model is the one served here. It loads on the first request and is released after fifteen idle minutes.

Limits

What to expect

It was trained on 70 contracts drawn from five standard Saudi templates (limited liability, holding, joint stock, general partnership, limited partnership) and tested on 15 it had not seen. Contracts in those formats work well. A contract written in a very different style will be read less reliably. Long clauses near the end are found but their edges are loose, and the liquidation clause is still missed outright: only about a dozen training contracts contain it. This is a reading aid, not legal advice.