brendon-ai commited on
Commit
2cd1b80
·
verified ·
1 Parent(s): 0cf14e5

Update src/RAGSample.py

Browse files
Files changed (1) hide show
  1. src/RAGSample.py +15 -12
src/RAGSample.py CHANGED
@@ -355,25 +355,28 @@ def setup_rag_chain() -> Runnable:
355
  """Sets up the RAG chain with a prompt template and an LLM."""
356
  # Define the prompt template for the LLM
357
  prompt = PromptTemplate(
358
- template="""You are a knowledgeable medical information assistant providing answers based on verified medical documents and FAQs.
359
-
 
 
360
  Instructions:
361
- - If asked about your identity or role, respond: "I am a medical information assistant designed to help answer health-related questions based on verified medical documents."
362
- - For medical questions: Answer based solely on the provided documents - do not use external knowledge
363
- - If the question is not medical-related, politely redirect: "I specialize in medical information. Please ask a health-related question."
364
- - Use clear, patient-friendly language while maintaining medical accuracy
365
- - If the documents don't contain sufficient information for medical questions, state "I don't have enough information in the provided documents to answer this question"
366
- - For serious symptoms or concerns, always recommend consulting healthcare professionals
367
- - Keep responses concise (2-4 sentences maximum)
368
- - This information is for educational purposes only
369
 
370
- Question: {question}
371
  Documents: {documents}
372
 
373
- Answer:""",
 
 
374
  input_variables=["question", "documents"],
375
  )
376
 
 
377
  try:
378
  tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
379
  model = AutoModelForCausalLM.from_pretrained(
 
355
  """Sets up the RAG chain with a prompt template and an LLM."""
356
  # Define the prompt template for the LLM
357
  prompt = PromptTemplate(
358
+ template="""Context: You are a medical information assistant that answers health questions using verified medical documents.
359
+
360
+ Primary Task: Answer the medical question using ONLY the provided documents.
361
+
362
  Instructions:
363
+ 1. For medical questions: Provide a clear, accurate answer based solely on the document content
364
+ 2. If documents lack sufficient information: "I don't have enough information in the provided documents to answer this question"
365
+ 3. For non-medical questions: "I specialize in medical information. Please ask a health-related question."
366
+ 4. For identity questions: "I am a medical information assistant designed to help answer health-related questions based on verified medical documents."
367
+ 5. Always use patient-friendly language
368
+ 6. Keep responses 2-4 sentences maximum
369
+ 7. For serious symptoms, recommend consulting healthcare professionals
 
370
 
 
371
  Documents: {documents}
372
 
373
+ Question: {question}
374
+
375
+ Medical Answer:""",
376
  input_variables=["question", "documents"],
377
  )
378
 
379
+
380
  try:
381
  tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
382
  model = AutoModelForCausalLM.from_pretrained(