Skip to content

Instantly share code, notes, and snippets.

@csenio
Created May 11, 2023 15:53
Show Gist options
  • Save csenio/8b0e0fb93a3038f2e3af3bd40846aa42 to your computer and use it in GitHub Desktop.
Save csenio/8b0e0fb93a3038f2e3af3bd40846aa42 to your computer and use it in GitHub Desktop.
const tenses = {
present_tense: 'Presente',
preterite_tense: 'Pretérito',
imperfect_tense: 'Imperfecto',
future_tense: 'Futuro',
conditional_tense: 'Condicional',
subjunctive_mood: 'Subjuntivo',
}
// array of tuples of [input, output]
const training_prompts = [
[
{key_term: 'ser', supporting_terms: [], tense: tenses.present_tense},
{spanish: '{{Soy}} humano.', english: '{{I am}} human.'},
],
[
{key_term: 'estar', supporting_terms: [], tense: tenses.present_tense},
{spanish: '{{Estoy}} estresado.', english: '{{I am}} stressed.'},
],
[
{key_term: 'tener', supporting_terms: ['noche'], tense: tenses.present_tense},
{spanish: '¿{{Tienes}} planes para esta [[0-noche]]?', english: '{{Do you have}} plans for [[0-tonight]]?'},
],
[
{key_term: 'tener que', supporting_terms: ['perfecto'], tense: tenses.present_tense},
{spanish: '{{Tengo}} que ser [[0-perfecto]].', english: '{{I have}} to be [[0-perfect]].'},
],
[
{key_term: 'derecho', supporting_terms: ['aprobar'], tense: tenses.preterite_tense},
{
spanish: 'Las Naciones Unidas [[0-aprobó]] la Declaración Universal de los {{Derechos}} Humanos en 1948.',
english: 'The United Nations [[0-approved]] the Universal Declaration of Human {{Rights}} in 1948.',
},
],
[
{key_term: 'hacer', supporting_terms: ['derecho'], tense: tenses.present_tense},
{spanish: 'No tienes [[0-derecho]] a {{hacer}} esto.', english: 'You have no [[0-right]] to {{do}} this.'},
],
[
{key_term: 'poder', supporting_terms: ['nada'], tense: tenses.present_tense},
{spanish: 'No {{puedo}} hacer [[0-nada]].', english: "I {{can't}} do [[0-anything]]."},
],
[
{key_term: 'ir', supporting_terms: ['concierto', 'amigos'], tense: tenses.present_tense},
{
spanish: '{{Voy}} al [[0-concierto]] con mis [[1-amigos]].',
english: '{{I am going}} to the [[0-concert]] with my [[1-friends]].',
},
],
[
{key_term: 'coche', supporting_terms: ['colegio', 'venir'], tense: tenses.future_tense},
{
spanish: 'Mañana [[1-vendré]] al [[0-colegio]] en mi {{coche}}.',
english: 'I [[1-will come]] to [[0-school]] in my {{car}} tomorrow.',
},
],
]
// create jsonL file from training prompts
const fs = require('fs')
const jsonL = training_prompts.map(([input, output]) => {
return {
prompt: JSON.stringify(input),
completion: JSON.stringify(output),
}
})
fs.writeFileSync('training_data.jsonl', jsonL.map(JSON.stringify).join('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment