Topic classifier for Istanbul court records (31 classes, multi-label)

This is small neural network (MLP) that assigns any number of legal topics (none, one or several) to a transliterated Ottoman Turkish court record. It runs on top of frozen Qwen3-Embedding-8B document vectors. It does not read the text itself: you embed the record with Qwen3-Embedding-8B first, then pass the vector to this model.

The records it was built for are the Istanbul court registers (sicil) provided by ISAM and available at kadisicilleri.org. I have already run the model on all 54,670 records, so for those records you can use the published labels instead of running the model yourself: enesyila/ota-istanbul-court-records-topics. You need this model only for new texts.

The topics are model predictions, not human annotations. Please read the limitations below before using them.

Related resources

Resource Role
enesyila/ota-istanbul-court-records-embeddings The Qwen3-Embedding-8B vectors (4,096 dimensions, one per record, matched by id) that this model was trained on. The vectors were taken from this dataset and not computed again for training.
enesyila/ota-istanbul-court-records-topics The records classified with this model: predicted topics and the score for each class. The id of each record is its record number on kadisicilleri.org.

Due to copyright restrictions, the record texts are not published in these repositories. To read a record, open https://www.kadisicilleri.org/ayrmetin.php?idno=<id>, for example idno=51.

Files

  • mlp_topic_classifier.pt: five networks (five random seeds, averaged), the input scaler of each network, the 31 class names and one decision threshold per class.

Output

For every record the model gives a score between 0 and 1 for each of the 31 classes. A class is returned when its score reaches that class's threshold.

  • The classes are decided independently, so a record can have no label, one label or several. This is useful because a record can touch several topics, such as divorce and violence.
  • The scores are not calibrated probabilities. A score of 0.9 does not mean that 90% of such labels are correct. Thresholds differ by class (they were chosen for the best F1 per class), so 0.5 is not the cut-off. Use the scores for ranking and for choosing records to review.

Classes

Each record can be assigned any of 31 legal topics. The base of the taxonomy is from Akça (2005), although I made some updates. The first letter of a class name is its group. Groups A to D follow the topic scheme of an MA thesis on a register of the Üsküdar court (Sümeyye Akça, Üsküdar Kadılığı 23 Nolu ve H. 968-970 Tarihli Sicilin Diplomatik Yönden İncelenmesi: Metin ve İnceleme, MA thesis, Marmara Üniversitesi, İstanbul 2005). I added Group E for record types that the thesis scheme does not cover. Some of them like ferman are not actually a legal topic but an important topic to be labelled. Later, I may need to revise the taxonomy.

The descriptions below are the working definitions used to build the training labels. They were written for this project, so they can differ from the thesis wording. A class applies when the record is about the topic, even if it also has other topics.

If you have any suggestions to improve the taxonomy, please contact me. I am more than happy to improve the taxonomy to better align with the interest of historians.

A. Law of persons (Şahıs hukuku ile ilgili kayıtlar)

Class Description
A_kole Slavery: status or transaction of a slave, including a runaway slave caught and returned, manumission, a mukataba (self-purchase) contract, a freedom claim, sale or return of a female or male slave. Slaves who appear only as offenders do not count.
A_vasi_vesayet Guardianship: appointment, dismissal or acts of a guardian or testamentary executor for minors or incapable persons. A trustee for an absent person alone does not count.
A_is_akdi Hire of labour: wages, service, domestic or manual work, claims for pay. Not apprenticeship, rent of property or official wage tariffs.
A_vakif Pious foundation (waqf): a waqf as subject or party, including appointment of its administrator, foundation deeds, waqf property, debts to or from a waqf.
A_nikah Marriage: marriage contract, remarriage, validity of a marriage. A dower mentioned only as a term of the contract does not count as alimony-dower.
A_talak Divorce: the divorce itself, such as repudiation, divorce by mutual release, irrevocable divorce. Claims after a divorce get their own topic (often alimony-dower).
A_nafaka_mihir Alimony and dower: alimony or maintenance (for a spouse or child) and dower claims. Not maintenance of slaves or animals.

B. Inheritance law (Miras hukuku ile ilgili kayıtlar)

Class Description
B_miras Inheritance: heirs and inheritance rights (who the heirs are, shares, disputes between heirs).
B_vasiyet Will: a bequest effective after death, manumission by will, a will executor.
B_tereke Estate: the estate of a deceased person (inventory, division, debts paid from it or owed to it). Often together with inheritance.

C. Obligations, property and commercial law (Borçlar, eşya ve ticaret hukuku ile ilgili kayıtlar)

Class Description
C_deyn Debt: a debt or money claim.
C_ibra_sulh Release and settlement: release from a claim, settlement, waiver, or withdrawal of a lawsuit.
C_kefalet_vekalet Guarantee and agency: a guarantee (a guarantor for a person or for money) or the appointment of an agent.
C_rehin_emanet Pledge and deposit: a pledge securing a debt, or a deposit left for safekeeping.
C_bey Sale: a sale or purchase of any thing (house, land, shop licence, animal, slave, goods), including sale as security.
C_iltizam Tax farming: collecting a state or waqf revenue for a yearly sum, the tax farmer. Not a waqf life-lease.
C_narh Official prices: official price lists and price fixing, selling above or below the official price. The tax farm of market inspection belongs to tax farming, not here.
C_kusurlu_mal Defective goods: defective goods returned or contested, and market inspection findings of short weight or short bread.

D. Criminal law (Ceza hukuku ile ilgili kayıtlar)

Class Description
D_sirkat Theft: burglary, stolen goods found and returned, a person accused of theft. Seizure of property by force alone is not theft.
D_katl_cerh Killing and wounding: a body found or examined, murder claims, blood money, retaliation, stabbing or shooting injuries.
D_fuhus_zina Adultery and prostitution: a man and woman caught together, accusations of adultery, rape claims. An insult that merely uses such words is an insult case.
D_setm Insults: insults and swearing, defamation.
D_darb Beating: a person beaten with a stick or fist, a complaint about a beating or its settlement.
D_tarik_yer Neighbour and building disputes: a wall, window, latrine or well harming a neighbour, a building blocking the road, nuisance. Not an ordinary sale of land or a house.
D_icki Alcohol: drinking wine, the smell of wine on a person, taverns, sale or import of liquor.
D_kacak_giris_cikis Unauthorized entry or exit: persons or goods crossing a strait or city entrance against an order, smuggling of captives, forbidden persons entering.

E. Added by the model author (administration, taxation, guilds and ownership)

Class Description
E_ferman_emr Imperial order: a command from above, meaning an order of the sultan or of the central government in his name, addressed to the judge, officials or the population, or its registration in the register. Not a case that merely mentions an earlier order.
E_berat_tayin Appointment to office: appointment, dismissal or confirmation to an office or post, and patents of appointment (guild wardens, imams, preachers, muezzins, waqf administrators, police chiefs, deputy judges, clerks); renewal of a lost patent; trade patents for foreign merchants.
E_esnaf_lonca Guilds and crafts: guild and craft organisation, a guild's warden, guild rules, disputes between guilds or between a guild and a member, transfer of a business licence or its tools, the market inspection office.
E_vergi_avariz Taxes and levies: poll tax, extraordinary levies, land and produce taxes, fees, exemptions, their collection, complaints about unlawful levies. A tax-farming contract also gets tax farming. Not a private loan from a levy foundation.
E_mulkiyet_hibe Ownership and gifts: gifts, donations, transfers of ownership; ownership claims and disputes over a house, land or goods, seizure, title-deed grants. A gift of a dower or a debt between spouses also counts. Not a sale, an inheritance dispute or a waqf.

Records about other subjects were not modelled. There is no "other" class, so such a record may have no topic or the nearest one.

Training data

3,061 labelled records, split into train (2,037), dev (515) and test (509). Records that share a summary_group are always in the same split. In the topics dataset, these records have train, dev or test in the split column. Each record has one cell per class:

  • 1: the class was confirmed present,
  • 0: the class was checked and found absent, or both source label sets said it was absent,
  • -1: unknown. These cells are left out of training and scoring (about 3% of all cells).

I did not check all these 3,061 documents for all possible classes. What I did was to make annotations for the presence of a topic in a single document. So, if a document has five topics indeed, my annotation may cover just one of them. Thanks to the training logic, the missing labels are not an issue.

Method

  • Input: 4,096-dimensional Qwen3-Embedding-8B vectors (L2-normalised) from the embeddings dataset, standardised with a scaler fitted on the training part.
  • Network: one hidden layer of 512 units (GELU), dropout 0.1 on the input and 0.3 after the hidden layer, 31 sigmoid outputs.
  • Loss: binary cross-entropy that ignores unknown cells, with a positive weight per class (square root of the negative-to-positive ratio, between 1 and 10).
  • Optimiser: AdamW, learning rate 1e-3, weight decay 1e-2, 14 epochs (chosen by early stopping on dev).
  • Final model: five seeds, averaged; fitted on train and dev together.
  • Thresholds: one per class, chosen for the best F1 from out-of-fold predictions of a 5-fold cross-validation grouped by summary_group.

Test results

On the held-out test split of the labelled data (509 records), with thresholds from cross-validation:

macro-F1 micro-F1 macro-AP
0.826 0.847 0.903

The macro average includes D_kacak_giris_cikis, which has a single positive in the test split; without it the macro-F1 over the other 30 classes is about 0.85.

Class Test positives F1 AP
A_kole 19 0.97 0.96
A_vasi_vesayet 22 0.82 0.90
A_is_akdi 18 1.00 1.00
A_vakif 26 0.85 0.98
A_nikah 19 0.92 0.97
A_talak 20 1.00 1.00
A_nafaka_mihir 23 0.94 0.99
B_miras 23 0.68 0.78
B_vasiyet 21 0.95 0.99
B_tereke 24 0.70 0.79
C_deyn 24 0.79 0.87
C_ibra_sulh 28 0.78 0.90
C_kefalet_vekalet 26 0.71 0.78
C_rehin_emanet 19 0.94 0.97
C_bey 23 0.83 0.91
C_iltizam 18 0.82 0.95
C_narh 18 0.88 0.99
C_kusurlu_mal 19 0.92 0.97
D_sirkat 19 0.59 0.64
D_katl_cerh 20 0.90 0.97
D_fuhus_zina 18 0.82 0.92
D_setm 20 0.82 0.89
D_darb 21 0.74 0.85
D_tarik_yer 15 0.97 1.00
D_icki 19 0.89 0.95
D_kacak_giris_cikis 1 0.00 0.50
E_ferman_emr 21 0.89 0.94
E_berat_tayin 17 0.91 0.98
E_esnaf_lonca 17 0.73 0.75
E_vergi_avariz 15 0.91 0.95
E_mulkiyet_hibe 18 0.91 0.96

With 15 to 28 positives per class, single-class scores are noisy.

Limitations

  • Predictions, not ground truth. I did not manually check the labels this model produces for the full corpus. Errors are expected.
  • Rare classes are weak. D_kacak_giris_cikis has too few examples to be scored reliably (it was predicted for only 4 of the 54,670 records).
  • It depends on the embedding model. Use the same model, Qwen/Qwen3-Embedding-8B, with normalised vectors, as in the example below. Vectors from other models will not work. Later, an LLM can be used to do the classification directly on the text without using embeddings.

Usage

import torch
from sentence_transformers import SentenceTransformer

ck = torch.load('mlp_topic_classifier.pt', weights_only=True)

st = SentenceTransformer('Qwen/Qwen3-Embedding-8B',
                         model_kwargs={'torch_dtype': torch.bfloat16},
                         tokenizer_kwargs={'padding_side': 'left'})
st.max_seq_length = 32768

texts = ['...']   # transliterated record text
X = torch.tensor(st.encode(texts, normalize_embeddings=True, batch_size=4), dtype=torch.float32)

P = 0
for m in ck['members']:
    net = torch.nn.Sequential(
        torch.nn.Dropout(0.1), torch.nn.Linear(ck['in_features'], ck['hidden']), torch.nn.GELU(),
        torch.nn.Dropout(0.3), torch.nn.Linear(ck['hidden'], len(ck['class_names'])))
    net.load_state_dict(m['state_dict']); net.eval()
    with torch.no_grad():
        P = P + torch.sigmoid(net((X - m['mean']) / m['scale'])) / len(ck['members'])

labels = [[c for c, p, t in zip(ck['class_names'], row, ck['thresholds']) if p >= t] for row in P]

P holds the 31 scores per record, and labels the classes that reached their thresholds.

To apply the model to the vectors in the embeddings dataset without running Qwen3-Embedding-8B again, load the vectors from that repository and use them as X in the code above.

Copyright and license

The model weights, the thresholds and the class definitions are licensed under CC BY-NC 4.0. You may share and adapt them for non-commercial purposes as long as you give credit. Please cite this model, and the thesis for the class scheme (see Classes).

The model uses Qwen3-Embedding-8B to embed texts, which has its own license; check its terms before you use it. The CC BY-NC 4.0 license does not cover the texts of the records. The texts have their own copyright and terms, held by their respective rights holders. Check the terms of the original source, kadisicilleri.org, before you reuse them. Nothing in this card grants rights to the record texts.

Contact

enes.yilandiloglu@helsinki.fi

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for enesyila/ota-istanbul-court-topic-classifier

Finetuned
(51)
this model

Collection including enesyila/ota-istanbul-court-topic-classifier