spindle-bge-base-motifs

The search model behind Spindle, a search engine for Stith Thompson's Motif-Index of Folk-Literature that runs entirely in the browser. You describe a motif or a plot fragment in plain words ("a princess sleeps until a kiss wakes her"), and the model finds the motifs that match.

It is BAAI/bge-base-en-v1.5, fine-tuned so that plot fragments and half-remembered descriptions land near the motifs they illustrate. This repository holds the 8-bit ONNX version for transformers.js.

This is the second version (October 2026). It adds queries written from real tales to the training data; the first version is in the commit history.

Use

Queries take bge's retrieval prompt. Motif texts (Thompson's headline plus his note) are embedded without it. Use CLS pooling and normalise.

import { pipeline } from '@huggingface/transformers';

const embed = await pipeline('feature-extraction', 'folgertk/spindle-bge-base-motifs', { dtype: 'q8' });
const prompt = 'Represent this sentence for searching relevant passages: ';
const q = await embed(prompt + 'a princess sleeps until a kiss wakes her', { pooling: 'cls', normalize: true });

Training

Two kinds of training pair, each a query and the motif it should find:

  • About 1,800 plot fragments from Hans-Jörg Uther's summaries of ATU tale types (The Types of International Folktales, 2004), with the motif he cites for each. Each has three mined hard negatives: motifs the base model ranked highly that are neither the cited motif nor its parent or child.
  • 4,740 search queries written from 688 folktales in D. L. Ashliman's Folktexts. Uther lists the motifs of each tale type; Claude Sonnet found the passage where a given telling expresses one of them, then, seeing only that passage and never the motif's number or wording, wrote what someone half-remembering the episode might type: a vague line, a fuller description and a few keywords. Passages whose motif a second check found not to fit were dropped. These pairs take random negatives rather than mined ones, because a tale passage usually expresses several motifs and the model's near misses are often right.

Both come from the trilogy dataset, and both are split by tale type: 60% for training, 20% for development and 20% for testing, so the test queries come from tale types the model never saw. Training ran for 3 epochs with MultipleNegativesRankingLoss, at learning rate 2e-5 and batch size 32.

Evaluation

All 46,220 motifs are searched, at full precision. Each motif also has a second vector, a short paraphrase written by Claude Haiku, as Spindle uses it.

ATU fragments: 687 fragments from 296 unseen tale types.

Right motif first In the top 10 MRR
bge-base-en-v1.5, no readings 27% 46% 0.33
version 1 34% 58% 0.42
this model 34% 57% 0.41

Tale queries: 1,600 queries (passages and blind descriptions) from 396 passages of 30 unseen tale types. Because a telling holds more motifs than Uther lists, Claude Sonnet also judged the top results of each model; the "judged" columns count any motif it judged a folklorist would cite.

In the top 10 MRR In the top 10, judged MRR, judged
version 1 47% 0.28 75% 0.50
this model 51% 0.31 79% 0.54

In the browser, with these 8-bit weights and Spindle's compressed motif vectors, the tale queries come to 49% / 0.30 (version 1: 44% / 0.25) and the ATU fragments to 55% / 0.40 for both.

Limitations

The training queries are Uther's phrasing and Claude's, of mostly European tale types, so queries in that register work best. Raw passages from a tale are harder than a description of the episode. The judged scores rely on a language model's judgment, checked by hand only on samples.

Licence and credits

The base model, bge-base-en-v1.5 by BAAI, is MIT-licensed. The fine-tuning data come from the trilogy dataset by Joshua Hagedorn, under CC BY-SA 4.0, so this model is shared under the same licence. The model contains no text from the summaries or the tales. Built by Folgert Karsdorp.

Downloads last month
123
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for folgertk/spindle-bge-base-motifs

Quantized
(31)
this model