From 5b7d1cb49bd473c7dbcf6e89f7d1b6fc8be1f5b1 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Thu, 11 Apr 2024 08:59:41 +0200 Subject: Improve prompt --- rag/generator/ollama.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'rag/generator/ollama.py') diff --git a/rag/generator/ollama.py b/rag/generator/ollama.py index abd5599..6340235 100644 --- a/rag/generator/ollama.py +++ b/rag/generator/ollama.py @@ -7,7 +7,7 @@ from loguru import logger as log from rag.retriever.vector import Document from .abstract import AbstractGenerator -from .prompt import Prompt +from .prompt import ANSWER_INSTRUCTION, Prompt class Ollama(metaclass=AbstractGenerator): @@ -23,13 +23,11 @@ class Ollama(metaclass=AbstractGenerator): def __metaprompt(self, prompt: Prompt) -> str: metaprompt = ( - "Answer the question based only on the following context:" + "Answer the question based only on the following context:\n" "\n" f"{self.__context(prompt.documents)}\n\n" "\n" - "Given the context information and not prior knowledge, answer the question." - "If the context is irrelevant to the question, answer that you do not know " - "the answer to the question given the context.\n" + f"{ANSWER_INSTRUCTION}" f"Question: {prompt.query.strip()}\n\n" "Answer:" ) -- cgit v1.2.3-70-g09d2