Research record

Status
Completed measurement · dev split
MESA version
MESA 0.9.4 query logic; rank change from a pre-release 0.9.4 build
Dataset
Benchmark v2 dev, Tier M, 141 documents, 112 answerable questions
Models
No model; T0 lexical search
Metrics
token match type · forms per prefix · Hit@5

Known limitations

  • Token analysis checks the gold evidence span, not every candidate passage.
  • It does not apply MESA's citation-token filtering.
  • A prefix-only match in the evidence does not prove that prefix matching caused a rank change.
  • One Turkish legal corpus.

Why does BM25 struggle with Turkish?#

BM25 scores whole tokens, and Turkish builds many tokens from one stem. sözleşme, sözleşmesinin and sözleşmelerinde are three different index terms, so a query containing one form can miss the others.

We measured this on MESA's Turkish legal benchmark. Of 873 eligible query terms in 112 answerable dev questions, 290 appeared exactly in the correct evidence, 252 matched only through their first five characters, and 331 did not match at all. Prefix matching addresses the middle group, but its measured gain was small: a net two questions in the top 5.

How many forms does one Turkish word have?#

We indexed the 141 Tier M documents with the tokenizer MESA uses and grouped every term of 6 or more characters by its first five characters. The tokenizer removes most diacritics, so sözle is stored as sozle.

Tier M corpus, terms with 6+ charactersValue
Distinct terms26,664
Five-character prefix groups5,144
Median forms per group2
90th percentile12
Groups with 10 or more forms670
Groups with 50 or more forms58
Largest group191
PrefixForms in corpusExamples
karar87kararı, kararın, kararlarına, kararnamenin
yonet55yönetim, yönetmelik, yönetmeliğin, yönetici
sozle44sözleşme, sözleşmesinin, sözleşmelerinde
yargı41yargıtay, yargılama, yargısal
madde39maddesi, maddesinde, maddelerine
mahke38mahkemesi, mahkemece, mahkemelerinin

Most prefix groups are small. The problem concentrates in common legal words, and those are the words legal queries use.

How often do query words miss the evidence?#

Dev category, eligible query termsExact in evidencePrefix onlyNo match
Exact wording956691
Number, date, docket888593
Paraphrase6361119
Cross-document444028
All290252331

In 102 of 112 answerable questions, at least one query term reached the evidence only through its prefix. Paraphrases have the largest no-match group: 119 of 243 terms. Prefix matching cannot help there, because the words differ. That is where semantic search and hybrid retrieval come in.

How does MESA's prefix matching work?#

MESA 0.9.4 uses a simple rule. A query token with 6 or more characters and no digits is truncated to five characters and searched as a prefix. Shorter tokens and tokens with digits stay exact, so 6098 cannot match 60981.

You can see the behavior with Python's standard library, using the same FTS5 tokenizer settings:

Worked example
import sqlite3

db = sqlite3.connect(":memory:")
db.execute("""CREATE VIRTUAL TABLE docs USING fts5(
    text, tokenize='unicode61 remove_diacritics 2', prefix='5')""")
rows = ["Yargıtay kararı", "YARGITAY KARARI", "sözleşmesinin feshi", "sözlerini söyledi"]
db.executemany("INSERT INTO docs VALUES (?)", [(r,) for r in rows])

for query in ['"sözleşme"', '"sözle"*', '"yargı"*', '"yargi"*']:
    hits = [r[0] for r in db.execute("SELECT text FROM docs WHERE docs MATCH ?", (query,))]
    print(query, "->", hits)
Worked example
"sözleşme" -> []
"sözle"* -> ['sözleşmesinin feshi', 'sözlerini söyledi']
"yargı"* -> ['Yargıtay kararı']
"yargi"* -> ['YARGITAY KARARI']

The output shows both sides of the rule. sözle* finds sözleşmesinin, which the exact term misses. It also finds sözlerini, which has nothing to do with contracts.

Why are ı and İ a separate problem?#

Turkish has dotted and dotless i. In the output above, yargı* finds Yargıtay but not YARGITAY, because the tokenizer lowercases I to i rather than ı.

MESA handles part of this at query time. It normalizes Turkish case, then searches both the ı form and an i variant. So Yargıtay and YARGITAY as queries find text written either way. The ASCII query yargitay still does not find Yargıtay, because index-side Turkish folding is not implemented in 0.9.4.

What did prefix matching actually change?#

On a shared store with models off, prefix matching took dev Hit@5 from 50/112 to 52/112 (pre-release 0.9.4 build, benchmark v2, Tier M). Six questions crossed the top-5 line:

CategoryRank before → afterEffectPrefix-only terms in evidence
Number, date, docket6 → 5Gain2
Cross-document6 → 5Gain7
Number, date, docket6 → 5Gain3
Paraphrase38 → 4Gain0
Exact wording5 → 8Loss1
Number, date, docket4 → 11Loss5

Three gains were one-position moves. The largest gain had no prefix-only term in its evidence, so its improvement came indirectly, probably because competing passages changed rank. Both losses had prefix-only terms too. The presence of such a term does not predict whether a question improves.

The 0.9.4 quality post shows that larger gains came from changing fusion weights.

What should you do for Turkish search?#

  • Measure before adding a stemmer. Over-matching can cost as much as it gains.
  • Keep tokens with digits exact. Law numbers, dockets and dates must not match by prefix.
  • Handle ı and İ explicitly. Default Unicode lowercasing is wrong for Turkish.
  • Combine lexical search with embeddings, because many query words never appear in the evidence.
  • Compare ranks per question, not only an average.

What can this analysis not show?#

  • It checks each query term against the gold evidence span, not against all candidate passages.
  • It does not apply MESA's filtering of citation tokens, so counts are approximate for citation-heavy questions.
  • We did not test a real Turkish stemmer or morphological analyzer.
  • A net change of two questions in 112 is small and may not hold on another sample.
  • The corpus is legal text. General Turkish may behave differently.

Sources#

  1. SQLite FTS5 documentation
  2. Manning, Raghavan and Schütze: Okapi BM25
  3. MESA 0.9.4 changelog