msbayindir

Turkish NLP · Legal documents

Turkish legal NLP: BERT embeddings and Gemma 4 fine-tuning

Legal document search finds a relevant passage. Source-grounded answer generation then cites the evidence in that passage. I approach these as two distinct problems: publishing sentence encoders for Turkish legal texts and researching grounded answers with Gemma 4.

Semantic search over Turkish legal texts

Legal documents can discuss the same issue in different words. My BERTurk-based Sentence Transformers model turns a sentence or paragraph into a 768-dimensional vector. The Legal STS-B dataset provides text pairs and similarity scores for training and evaluation. These representations can help identify candidate passages in legislation and court decisions.

The BERT and XLM-RoBERTa Fill-Mask models on Hugging Face predict masked text from its context. The embedding models I published produce vectors for comparing and ranking passages.

What the model card scores measure

The BERTurk STS card reports Pearson 0.9701 and Spearman 0.9688 on sts-test. These correlations describe agreement between predicted and reference similarity scores. A search system also needs a separate evaluation using queries with known relevant documents to show whether it retrieves the right sources near the top.

The Gemma 4 fine-tuning pilot

I am using LoRA with Gemma 4 E4B to study how the model answers from supplied passages and identifies the supporting text. The pilot covers identifying relevant provisions, answering questions from sources, and extracting fields from court decisions.

I check whether a citation refers to the supplied material, whether that material actually supports the answer, and whether the model expresses uncertainty when the source is insufficient. These checks help expose answers that sound fluent but have weak evidence.

Sources

Related projectTurkish Legal Language Models