summaryrefslogtreecommitdiff
path: root/rag/generator/ollama.py
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2024-04-11 08:59:41 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2024-04-11 08:59:41 +0200
commit5b7d1cb49bd473c7dbcf6e89f7d1b6fc8be1f5b1 (patch)
tree41a19d0ff59cb00eca6e30511bbe2d54996b4b2a /rag/generator/ollama.py
parent98f8d1d535c30d8c1ca6c7b52e634a99b88acf10 (diff)
Improve prompt
Diffstat (limited to 'rag/generator/ollama.py')
-rw-r--r--rag/generator/ollama.py8
1 files changed, 3 insertions, 5 deletions
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"
"<context>\n"
f"{self.__context(prompt.documents)}\n\n"
"</context>\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:"
)