{"version":3,"file":"prompt.cjs","names":["PromptTemplate"],"sources":["../../../src/evaluation/comparison/prompt.ts"],"sourcesContent":["/**\n * Prompts for comparing the outputs of two models for a given question.\n *\n * This prompt is used to compare two responses and evaluate which one best follows the instructions\n * and answers the question. The prompt is based on the paper from\n * Zheng, et. al. https://arxiv.org/abs/2306.05685\n */\n\nimport { PromptTemplate } from \"@langchain/core/prompts\";\n\nconst template = `Act as a fair judge and rate the two responses to the question below.\\\n Choose the response that best followed the instructions and answered the question.\\\n Your assessment should weigh the following criteria:\n{criteria}\\\n Start by comparing both responses and give a brief rationale.\\\n Avoid bias from the order of presentation or response length.\nAfter giving your rationale, make your final decision using this format:\\\n \"[[A]]\" if assistant A is better, \"[[B]]\" if assistant B is better,\\\n and \"[[C]]\" for a tie. Finally, repeat the decision again on its own on a new line.\n\n[QUESTION]\n{input}\n[/QUESTION]\n\n[RESPONSE A]\n{prediction}\n[/RESPONSE A]\n\n[RESPONSE B]\n{predictionB}\n[/RESPONSE B]`;\n\nexport const PROMPT = /* #__PURE__ */ new PromptTemplate({\n  inputVariables: [\"input\", \"prediction\", \"predictionB\", \"criteria\"],\n  template,\n});\n\nconst referenceTemplate = `Act as a fair judge and rate the two responses to the question below.\\\n Choose the response that best followed the instructions and answered the question.\\\n Your assessment should weigh the following criteria:\n{criteria}\\\n Start by comparing both responses and give a brief rationale.\\\n Avoid bias from the order of presentation or response length.\\\n Weigh accuracy based on the following ground truth reference\\\n answer to the question:\n\n[REFERENCE]\n{reference}\n[/REFERENCE]\n\nAfter giving your rationale, make your final decision using this format:\\\n \"[[A]]\" if assistant A is better, \"[[B]]\" if assistant B is better,\\\n and \"[[C]]\" for a tie. Finally, repeat the decision again on its own on a new line.\n\n[QUESTION]\n{input}\n[/QUESTION]\n\n[RESPONSE A]\n{prediction}\n[/RESPONSE A]\n\n[RESPONSE B]\n{predictionB}\n[/RESPONSE B]`;\n\nexport const PROMPT_WITH_REFERENCES = /* #__PURE__ */ new PromptTemplate({\n  inputVariables: [\n    \"input\",\n    \"prediction\",\n    \"predictionB\",\n    \"reference\",\n    \"criteria\",\n  ],\n  template: referenceTemplate,\n});\n"],"mappings":";;AAgCA,MAAa,yBAAyB,IAAIA,wBAAAA,eAAe;CACvD,gBAAgB;EAAC;EAAS;EAAc;EAAe;EAAW;CAClE,UAxBe;;;;;;;;;;;;;;;;;;;;;CAyBhB,CAAC;AA+BF,MAAa,yCAAyC,IAAIA,wBAAAA,eAAe;CACvE,gBAAgB;EACd;EACA;EACA;EACA;EACA;EACD;CACD,UArCwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCzB,CAAC"}