Finding the right clause
How Kenning, a Turkish legal embedding model, finds the clause you meant instead of the one that shares your words, with a live map and the model card’s own scores, including where it is behind.
Imagine you run a small company that buys machinery. Everything that matters to you legally sits in one shared folder, all in Turkish: contracts, short summaries of court decisions and excerpts from regulations. A colleague asks a plain question:
The search finds nothing. The clause you want says that for every day of delay the buyer may demand a penalty: gecikilen her gün için … ceza isteyebilir. It never uses the word tazminat. Try the shorter word geç, “late”, and the search does return something, but it is a clause about reporting defects within eight days en geç, “at the latest”. Same word, different meaning, wrong clause.
A word search quietly assumes you can guess the words the author used. Legal Turkish makes that guess harder: people say one thing and contracts say another, and Turkish adds suffixes that change the ending of a word.
RuneLab’s Kenning Turkish Legal, released on 7 October 2026, is an embedding model built for exactly this problem: it is meant to put a legal question near the clause that answers it even when they share few words. In this post you move a question around a map to see the idea, read the scores on the model’s card, including where it trails another model, and see the code to try it. Every contract, decision and regulation here is invented for teaching, none of it is real law, and nothing in this post is legal advice.
By the end of this post you will know:
- what an embedding model changes about searching legal text, and why “nearest” is not the same as “correct”;
- what Kenning’s model card reports, including where it is behind another model and what the legal tuning cost elsewhere;
- how to run it on your own clauses, and what a person still has to check.
From words to points
#The idea behind this kind of search is not new, and How RAG finds answers builds it up from nothing with live figures, so here is the short version. An embedding model reads a piece of text and returns a list of numbers, which you can think of as a position. Texts about the same thing end up close together; texts about different things end up far apart. To search, you embed every passage once, embed the question the same way, and return the passages nearest to it.
It doesn’t look them up in a dictionary. The model was trained on large amounts of text, and one thing it picks up is that words and phrases used in similar situations should get similar positions. For everyday language that is often good enough. Legal Turkish is narrower: two clauses can sound alike and answer different questions (a late delivery and a faulty delivery both mention the seller, the buyer and the goods), and two clauses that answer the same question can share almost no words. A model tuned on legal text should have seen more of this. That is the bet behind Kenning.
What Kenning is, and what it is not
#Kenning Turkish Legal is a RuneLab model: Turkish legal retrieval embeddings, fine-tuned from Google’s EmbeddingGemma 2 (271M parameters; the model itself is listed at 0.3B). It was released on 7 October 2026 under the Apache 2.0 license, a day after its base model. It handles Turkish and English, and the scores on its card are measured at 768 numbers per text.
The card says what it is for: semantic search over Turkish legal documents (contracts, case law and regulation), first-stage retrieval in RAG pipelines, and candidate retrieval for legal research tools that include human review. It also says what it is not for: general Turkish embedding work, text similarity as the main goal, and legal collections from other languages or jurisdictions. And it asks that people check the results.
The name is a small joke about what an embedding does. A kenning is an Old Norse poetic device that names a thing by a figurative compound, “whale-road” for the sea. An embedding restates what a text means in a compressed form, which has some of the same flavour. Kenning is a RuneLab model; it is not one of the Hati or Sköll models.
Which clause answers it?
#Here is the folder in miniature: twelve invented passages, in Turkish with an English reading under each, about four legal questions (late delivery, faulty goods, unpaid rent and rent increases). Each dot on the map is one passage:
Before you press anything, guess whether the ringed passage is among the three nearest. Then switch from the general layout to Kenning, pick the other questions, drag the star, or slide k. The layouts are drawn by hand to show an idea: they are not the output of any model.
This figure needs JavaScript. It shows twelve invented Turkish legal passages on a hand-drawn map. For the question about a late delivery, the passage that answers it (a delay penalty clause) is the 5th nearest in the general layout, so a search that fetches 3 passages misses it, and the 1st nearest in the Kenning layout. Over the four questions the answer passage is the 5th, 4th, 5th and 4th nearest in the general layout and the 1st, 1st, 2nd and 2nd nearest in the Kenning layout. Both layouts are illustrations, not measurements.
In the general layout the ringed clause is only the fifth nearest, so a search that fetches three never returns it. The three it does return are about something else: a delivery-date rule, a fault notice and a list of repair options. They share the question’s vocabulary (delivery, seller, buyer, even the word geç) without answering it. Switch to Kenning and the points glide: the clause about delay penalties lands next to the star and becomes the first result.
That is the mechanism in one sentence: fine-tuning moves legal paraphrases closer together, so the clause you need lands in the top k. Try the rent-increase question: in the general layout its answer is the fourth nearest, and k = 4 is enough to catch it, which is the same trade-off between missing an answer and reading more text that the RAG post explores.
Please don’t read the map as evidence. We placed these twelve points by hand. Real embeddings have hundreds of numbers each, not two; no real model produces groups this tidy; and we never ran a general model or Kenning on these passages. Even the Kenning layout is left a little untidy on purpose: the rent-increase notice sits between the two rent topics, so the unpaid-rent question pulls it in as its third result. The measurements come next.
In the figure, switching to Kenning pulls the answer clause next to the question. What does that show about the real model?
- That Kenning puts the right clause in the top three for most real questions.
- The idea only: both layouts are drawn by hand, and the measurements are in the card’s scores.
- That a general model can never find a legal clause.
Show answer
The figure is an illustration of what tuning is for. It measures nothing, so it cannot tell you how often the real model succeeds. That is what the scores in the next section are for.
Not A: a claim like “most real questions” needs real test questions and a count. The map has four invented questions and positions placed by hand.
Not C: the general layout misses on purpose, to show what a miss looks like. Real general models find legal clauses all the time: the base model in the next figure scores 76.73 on contracts.
What the scores say
#So what does the card actually report? It measures retrieval on a legal benchmark it calls Mizan, with three tasks (contracts, caselaw and regulation) and their mean. The metric is nDCG@10: it scores the first ten results of a search from 0 to 100, giving more credit when the passages a person would call relevant sit near the top and less when they sit lower down. These are RuneLab’s own measurements, taken at 768 numbers per text. The legal mean is simply the average of the three tasks.
Each row of the figure is one task. The
This figure needs JavaScript. It shows nDCG@10 on the legal benchmark. Legal mean: 48.44 for the base model, 50.94 for Kenning, 51.14 for bge-m3. Contracts: 76.73, 81.27, 86.08. Caselaw: 29.67, 30.51, 29.30. Regulation: 38.91, 41.04, 38.04. Kenning is above its base model on every row. Against bge-m3 it is behind on contracts (4.81 points) and on the legal mean (0.20 points) and ahead on caselaw (1.21) and regulation (3.00). On four general tests Kenning’s changes from its base model are −1.16, +0.17, −0.25 and +0.27 points.
Kenning is above its base model on every row: by 2.50 points on the legal mean, 4.54 on contracts, 0.84 on caselaw and 2.13 on regulation. Those gains are real, and they are smaller than the picture in the last figure made them look.
Against bge-m3 the picture is mixed. Kenning is behind on contracts, by 4.81 points, and slightly behind on the legal mean, by 0.20; it is ahead on caselaw, by 1.21 points, and on regulation, by 3.00. (These differences are computed from the rounded scores; the card states only the gains over the base model.) A gap of 0.20 is too small to call from one table. The contracts gap is not.
The third view shows what the tuning cost elsewhere. On four general tests the changes run from −1.16 to +0.27 points: Turkish semantic text similarity (STSbTR) is down 1.16, the English ten-task mean is down 0.25, and the Turkish fourteen-task and multilingual six-task means are up 0.17 and 0.27. The card lists general Turkish embedding work and similarity as the main goal among the things Kenning is not for, and the STSbTR drop is the one to remember if you plan to use it that way.
Which sentence matches the card’s table?
- bge-m3 scores higher than Kenning on every legal task.
- Kenning scores higher than bge-m3 on every legal task.
- Kenning is ahead of bge-m3 on caselaw and regulation, and behind it on contracts.
Show answer
Caselaw: 30.51 for Kenning against 29.30. Regulation: 41.04 against 38.04. Contracts: 81.27 against 86.08. The “Against bge-m3” view shows the same thing as bars either side of zero.
Not A: bge-m3 wins on contracts (86.08 against 81.27) and, narrowly, on the legal mean (51.14 against 50.94), but not on caselaw (29.30 against 30.51) or regulation (38.04 against 41.04).
Not B: on contracts Kenning scores 81.27 against 86.08, and its legal mean is also lower (50.94 against 51.14), as the first view of the figure shows.
How it was trained
#The card describes the recipe in a few lines. Kenning was fine-tuned with contrastive learning on about 17,000 pairs. A pair is two texts that belong together; the card does not say which texts, and the usual recipe is a question and the passage that answers it. Training pulls the two texts of a pair closer and pushes each of them away from the other texts in the batch.
The loss is called CachedMultipleNegativesRanking, wrapped inside a Matryoshka loss, with batches of 256, bf16 precision, a learning rate of 2e-5 and one pass over the data. In plain words, with a loss of this kind every text in a batch is compared with the 256 partner texts: one is right, 255 are wrong, and the model is rewarded for scoring the right one highest. “Cached” is a memory trick that makes such large batches possible, and “Matryoshka” means the first numbers of an embedding are trained to be useful on their own, like nested dolls, so an embedding can be cut shorter and still work.
The last line of the recipe is the surprising one: the released weights are averaged 50/50 with the base weights. A model is a long list of numbers, its weights. Take the base model’s list and the fine-tuned model’s list, average the two numbers at every position, and the result is the published model.
Try it yourself
#The model card gives the code, and the Kenning Turkish Legal page has the install line; the full card is on Hugging Face. Two details are easy to miss. Queries get the prompt task: search result | query: , and documents go through encode_document, not encode. The card reports its results at 768 numbers, so the example sets truncate_dim=768. The passages below are the invented ones from the figure.
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("runelab-ai/kenning-turkish-legal-v1", truncate_dim=768)
query_prompt = "task: search result | query: "
queries = ["Ürün geç gelirse satıcıdan tazminat isteyebilir miyiz?"]
documents = [
"Satıcı, malı sözleşmede yazılı günde teslim etmezse alıcı, gecikilen her gün için mal bedelinin binde ikisi kadar ceza isteyebilir.",
"Alıcı, teslim aldığı malda ayıp görürse bunu satıcıya en geç sekiz gün içinde yazılı olarak bildirmelidir.",
"Kira bedeli her kira yılının başında, taraflarca yazılı olarak kararlaştırılan oranda artırılır.",
# your own clauses go here
]
query_embeddings = model.encode(queries, prompt=query_prompt)
document_embeddings = model.encode_document(documents)
scores = model.similarity(query_embeddings, document_embeddings)
# The three nearest passages for the first question.
for rank, i in enumerate(scores[0].argsort(descending=True)[:3].tolist(), start=1):
print(rank, round(float(scores[0][i]), 3), documents[i][:70])
Install the pinned versions first (the card also notes that torchvision and pillow are needed): pip install "transformers==5.19.0" "sentence-transformers==6.1.0" torchvision pillow. The script prints the three nearest passages for the question. We list no output, because the passages are invented; run it on your own clauses and look at the ranking.
No, and the card says so: results should be checked by people. A high score means a passage is close in meaning to your question. It does not mean the passage is the law, that it is current, that it applies in your jurisdiction or that it says what a summary claims. Treat the top results as candidates to read.
You have 10,000 clauses to index and a question to ask. Which calls match the card’s example?
- Clauses with encode_document, and the question with encode plus the query prompt.
- Everything with encode and no prompt, because a clause and a question are both just text.
- The question with encode_document, and the clauses with encode plus the query prompt.
Show answer
The prompt marks a text as a query, so it goes on the question only, and the clauses go through encode_document. That is the pattern in the card’s example and in the code above.
Not B: the card gives these two details as the way to use the model. Leaving them out means using it differently from its own example, and its published scores say nothing about that.
Not C: that is backwards. The query prompt belongs on the question, and documents are what encode_document is for.
Before you point it at real contracts, test it the way the RAG post tests a search: collect real questions with the clauses that answer them and count how often the right clause lands in the top k. And remember that where your text goes depends on the whole setup, not on the model: you can run Kenning on hardware you control, but a chat tool or a hosted index around it may send text elsewhere.
Further reading
#Start with the Kenning model page and the model card on Hugging Face, where every number in this post comes from, and with How RAG finds answers for what happens after retrieval. The Matryoshka idea is from Kusupati and colleagues, “Matryoshka Representation Learning” (2022). Averaging the original and fine-tuned weights is studied in Wortsman and colleagues, “Robust fine-tuning of zero-shot models” (2021). The nDCG metric is from Järvelin and Kekäläinen, “Cumulated gain-based evaluation of IR techniques” (ACM Transactions on Information Systems, 2002).
This post leaves out a lot: how the base model was built, how Mizan was assembled (the card names it; we have not described how it was made), rerankers that re-read the top results, and everything about legal practice. The map, the passages and the layouts are teaching inventions; only the scores and the model facts come from the card.
What to do, and what not to do
#An embedding model turns a question and a pile of clauses into points, and searching is finding the nearest ones. Kenning is tuned so that more of the clauses that answer a Turkish legal question land near it: on the card’s own test it is above its base model on every task, level with bge-m3 on average and behind it on contracts. That makes it a useful first pass, and no more.
What to do:
- use it for what the card says: finding candidate passages in Turkish contracts, case law and regulation;
- test it on your own questions and clauses, and compare it with a general model before you choose;
- give queries the prompt, run documents through
encode_document, and show the passage next to every answer; - keep a person in the loop for anything that matters.
What not to do:
- treat the top result as legal advice, or as the law;
- use it for other languages or other legal systems, or as a general Turkish similarity model;
- read a hand-drawn map, or a gap of 0.20 points, as proof of anything;
- assume your documents stay on your machine just because the model can run there.
A tool shows a clause at rank 1 with a high similarity score. What would you check before relying on it?
Show answer
That it is the right document and the right version, still in force and for the right jurisdiction; that nothing later amends or replaces it; that it says what the tool’s summary claims; and that it answers your actual question. A similarity score says the text is close in meaning to your question. It does not say the text is correct, current or applicable, which is why the card asks for human review.
