File size: 1,824 Bytes
7f76651 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | const fs = require("fs");
const readline = require("readline");
// Загружаем датасет
const dataset = JSON.parse(fs.readFileSync("dataset.json"));
// Формируем единый промпт
let prompt = `Answer the following multiple choice questions. For each question, output the number of the question followed by a dot and the letter of the correct answer (A, B, or C). Output one answer per line, in order from 1 to N.
`;
dataset.forEach((item, idx) => {
const num = idx + 1;
prompt += `${num}. ${item.question}\n`;
prompt += `A. ${item.A}\n`;
prompt += `B. ${item.B}\n`;
prompt += `C. ${item.C}\n\n`;
});
console.log(prompt);
console.log("=== PUT HERE AI RESPONSE: ===");
console.log("1.A");
console.log("2.B");
console.log("3.C");
console.log("...");
console.log("(Then enter Ctrl+D)\n");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
let llmResponse = "";
rl.on("line", (line) => {
llmResponse += line + "\n";
});
rl.on("close", () => {
const lines = llmResponse.split(/\r?\n/);
const answers = {};
for (const line of lines) {
const match = line.match(/^(\d+)\.\s*([ABC])$/i);
if (match) {
const qNum = parseInt(match[1], 10);
const answerLetter = match[2].toUpperCase();
answers[qNum] = answerLetter;
}
}
let correct = 0;
for (let i = 0; i < dataset.length; i++) {
const expected = dataset[i].correct;
const predicted = answers[i + 1];
if (predicted && predicted === expected) {
correct++;
}
}
console.log(`\nFinal CowQA-Rapid score: ${correct}/${dataset.length} (${Math.round((correct / dataset.length) * 100 * 100) / 100})%`);
process.exit(0);
});
|