summaryrefslogtreecommitdiff
path: root/rag/generator
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2024-04-24 01:51:29 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2024-04-24 01:51:29 +0200
commit2e85325639ce3827cc2eb32f9750dfa873e3a480 (patch)
treec4b2c4e0877fb6a300c8e09c98df1478b32fe8c0 /rag/generator
parentf76660d052a79905748163b96c2cca8671ee8a24 (diff)
Experimenting with prompt
Diffstat (limited to 'rag/generator')
-rw-r--r--rag/generator/ollama.py12
-rw-r--r--rag/generator/prompt.py6
2 files changed, 10 insertions, 8 deletions
diff --git a/rag/generator/ollama.py b/rag/generator/ollama.py
index 9118906..52521ca 100644
--- a/rag/generator/ollama.py
+++ b/rag/generator/ollama.py
@@ -24,12 +24,14 @@ class Ollama(metaclass=AbstractGenerator):
def __metaprompt(self, prompt: Prompt) -> str:
metaprompt = (
- f"{ANSWER_INSTRUCTION}"
- "Only the information between <results>...</results> should be used to answer the question.\n"
- f"Question: {prompt.query.strip()}\n\n"
- "<results>\n"
+ "Context information is below.\n"
+ "---------------------\n"
f"{self.__context(prompt.documents)}\n\n"
- "</results>\n"
+ "---------------------\n"
+ f"{ANSWER_INSTRUCTION}"
+ "Do not attempt to answer the query without relevant context and do not use"
+ " prior knowledge or training data!\n"
+ f"Query: {prompt.query.strip()}\n\n"
"Answer:"
)
return metaprompt
diff --git a/rag/generator/prompt.py b/rag/generator/prompt.py
index f607122..10afe7b 100644
--- a/rag/generator/prompt.py
+++ b/rag/generator/prompt.py
@@ -4,9 +4,9 @@ from typing import List
from rag.retriever.vector import Document
ANSWER_INSTRUCTION = (
- "Given the context information and not prior knowledge, answer the question."
- "If the context is irrelevant to the question or empty, then do not attempt to answer "
- "the question, just reply that you do not know based on the context provided.\n"
+ "Given the context information and not prior knowledge, answer the query."
+ "If the context is irrelevant to the query or empty, then do not attempt to answer "
+ "the query, just reply that you do not know based on the context provided.\n"
)