SPB Git

spb/llmindex Public

The discriminative, contamination-resistant, fully transparent LLM ranking — updated live.

TypeScript 77.9% TeX 15.2% Python 3.7% SQL 1.4% JavaScript 1.1% Shell 0.5%
4.6 KB · 79 lines typescript
Raw Blame History
1/**2 * llmindex.io — knowledge item templates (fact bank + MC option shuffling + paraphrase)3 * Author:  Simon-Pierre Boucher4 * Contact: contact@spboucher.ai5 * License: Proprietary — © Simon-Pierre Boucher, all rights reserved6 *7 * Knowledge facts cannot be synthesized, so contamination resistance comes from8 * paraphrase variants + shuffled distractors; these templates are the main9 * anchor-eligible family and feed the contamination_delta measurement.10 */11import { ANSWER_FORMAT_INSTRUCTIONS } from '../answer';12import type { ItemTemplate } from '../types';1314interface Fact {15  q: string[];16  answer: string;17  distractors: string[];18}1920const CAPITALS: Fact[] = [21  { q: ['capital of Australia', 'Australian capital city'], answer: 'Canberra', distractors: ['Sydney', 'Melbourne', 'Perth', 'Brisbane'] },22  { q: ['capital of Canada', 'Canadian capital city'], answer: 'Ottawa', distractors: ['Toronto', 'Montreal', 'Vancouver', 'Calgary'] },23  { q: ['capital of Brazil', 'Brazilian capital city'], answer: 'Brasília', distractors: ['Rio de Janeiro', 'São Paulo', 'Salvador', 'Recife'] },24  { q: ['capital of Turkey', 'Turkish capital city'], answer: 'Ankara', distractors: ['Istanbul', 'Izmir', 'Antalya', 'Bursa'] },25  { q: ['capital of Switzerland', 'Swiss capital (de facto)'], answer: 'Bern', distractors: ['Zurich', 'Geneva', 'Basel', 'Lausanne'] },26  { q: ['capital of Kazakhstan', 'Kazakh capital city'], answer: 'Astana', distractors: ['Almaty', 'Shymkent', 'Karaganda', 'Aktobe'] },27  { q: ['capital of Myanmar', 'Burmese capital city'], answer: 'Naypyidaw', distractors: ['Yangon', 'Mandalay', 'Bago', 'Taunggyi'] },28  { q: ['capital of Nigeria', 'Nigerian capital city'], answer: 'Abuja', distractors: ['Lagos', 'Kano', 'Ibadan', 'Port Harcourt'] },29];3031const ELEMENTS: Fact[] = [32  { q: ['chemical element with symbol W', 'element whose symbol is W'], answer: 'Tungsten', distractors: ['Tin', 'Titanium', 'Tantalum', 'Terbium'] },33  { q: ['chemical element with symbol Hg', 'element whose symbol is Hg'], answer: 'Mercury', distractors: ['Hydrogen', 'Hafnium', 'Holmium', 'Helium'] },34  { q: ['chemical element with symbol K', 'element whose symbol is K'], answer: 'Potassium', distractors: ['Krypton', 'Calcium', 'Phosphorus', 'Carbon'] },35  { q: ['chemical element with symbol Sn', 'element whose symbol is Sn'], answer: 'Tin', distractors: ['Silicon', 'Selenium', 'Sodium', 'Scandium'] },36  { q: ['chemical element with symbol Sb', 'element whose symbol is Sb'], answer: 'Antimony', distractors: ['Strontium', 'Sulfur', 'Silver', 'Samarium'] },37  { q: ['chemical element with symbol Pb', 'element whose symbol is Pb'], answer: 'Lead', distractors: ['Platinum', 'Palladium', 'Polonium', 'Phosphorus'] },38];3940const AUTHORS: Fact[] = [41  { q: ['author of "One Hundred Years of Solitude"', 'writer of the novel "One Hundred Years of Solitude"'], answer: 'Gabriel García Márquez', distractors: ['Mario Vargas Llosa', 'Jorge Luis Borges', 'Julio Cortázar', 'Isabel Allende'] },42  { q: ['author of "Things Fall Apart"', 'writer of the novel "Things Fall Apart"'], answer: 'Chinua Achebe', distractors: ['Wole Soyinka', 'Ngũgĩ wa Thiong\'o', 'Ben Okri', 'Chimamanda Ngozi Adichie'] },43  { q: ['author of "The Master and Margarita"', 'writer of the novel "The Master and Margarita"'], answer: 'Mikhail Bulgakov', distractors: ['Fyodor Dostoevsky', 'Leo Tolstoy', 'Boris Pasternak', 'Anton Chekhov'] },44  { q: ['author of "Snow Country"', 'writer of the novel "Snow Country"'], answer: 'Yasunari Kawabata', distractors: ['Yukio Mishima', 'Haruki Murakami', 'Kenzaburō Ōe', 'Natsume Sōseki'] },45];4647const BANK: Fact[] = [...CAPITALS, ...ELEMENTS, ...AUTHORS];4849const STEMS = [50  'What is the {Q}?',51  'Name the {Q}.',52  'Identify the {Q}.',53];5455/**56 * Free-response (no options): removes the multiple-choice guessing floor57 * (c≈0 in IRT terms), restoring full item information at P≈0.5. Distractor58 * lists are retained for future buggy-solver MC variants but unused here.59 */60export const knowledgeMc: ItemTemplate = {61  id: 'knowledge.fr.factbank-v2',62  domain: 'knowledge',63  description:64    'Free-response facts from a curated bank with paraphrased stems — no options, no guessing floor.',65  paramSpace: BANK.length * STEMS.length * 2,66  render(rng, perturbSeed) {67    const fact = rng.pick(BANK);68    const stem = rng.pick(STEMS).replace('{Q}', rng.pick(fact.q));69    return {70      templateId: this.id,71      domain: this.domain,72      prompt: `${stem}\n\nAnswer with the name only — no explanation.\n\n${ANSWER_FORMAT_INSTRUCTIONS}`,73      answerKey: fact.answer,74      grading: 'exact',75      perturbSeed,76    };77  },78};79