wakeupmh commited on
Commit
8741970
·
1 Parent(s): e348a54

fix: prompt

Browse files
Files changed (1) hide show
  1. app.py +26 -38
app.py CHANGED
@@ -208,20 +208,19 @@ def generate_answer(question, context, max_length=512):
208
  clean_question = clean_text(question)
209
 
210
  # Format the input for T5 (it expects a specific format)
211
- input_text = f"""Answer the following question about autism using the provided research papers.
212
 
213
  Question: {clean_question}
214
 
215
- Research Papers:
216
  {clean_context}
217
 
218
- Instructions: Provide a detailed answer that:
219
- 1. Explains the main concepts clearly
220
- 2. Uses specific evidence from the research
221
- 3. Discusses practical implications
222
- 4. Notes any limitations
223
 
224
- Answer:"""
225
 
226
  try:
227
  # T5 expects a specific format for the input
@@ -235,7 +234,7 @@ Answer:"""
235
  outputs = model.generate(
236
  **inputs,
237
  max_length=max_length,
238
- min_length=100,
239
  num_beams=5,
240
  length_penalty=1.5,
241
  temperature=0.7,
@@ -252,37 +251,26 @@ Answer:"""
252
 
253
  # If response is too short or empty, provide a general overview
254
  if len(response.strip()) < 100:
255
- return f"""Here's what we know about autism in relation to your question:
 
 
 
 
 
 
256
 
257
- 1. General Understanding:
258
- - Autism Spectrum Disorder (ASD) is a complex neurodevelopmental condition
259
- - It affects how a person perceives, communicates, and interacts with the world
260
- - Each individual with autism has unique strengths and challenges
261
- - Early identification and support are crucial
262
 
263
- 2. Key Characteristics:
264
- - Social communication and interaction patterns
265
- - Repetitive behaviors and specific interests
266
- - Sensory sensitivities
267
- - Variable cognitive and language abilities
268
-
269
- 3. Important Considerations:
270
- - Autism is a spectrum, meaning it affects each person differently
271
- - Support needs vary from person to person
272
- - Many individuals with autism have unique talents and abilities
273
- - Research continues to improve our understanding
274
-
275
- 4. Current Research Areas:
276
- - Brain development and neurology
277
- - Genetic and environmental factors
278
- - Early intervention methods
279
- - Support strategies and therapies
280
-
281
- For more specific information, try asking about:
282
- - Specific autism characteristics
283
- - Diagnostic processes
284
- - Treatment approaches
285
- - Latest research findings"""
286
 
287
  # Format the response for better readability
288
  formatted_response = response.replace(". ", ".\n").replace("• ", "\n• ")
 
208
  clean_question = clean_text(question)
209
 
210
  # Format the input for T5 (it expects a specific format)
211
+ input_text = f"""Generate a comprehensive answer about autism that combines general knowledge with specific research findings.
212
 
213
  Question: {clean_question}
214
 
215
+ Recent Research:
216
  {clean_context}
217
 
218
+ Instructions: Create a response that:
219
+ 1. Starts with a general explanation about the topic
220
+ 2. Then adds specific findings from the research papers to support or expand the explanation
221
+ 3. Focuses on being helpful and informative for someone wanting to understand autism
 
222
 
223
+ Answer in Portuguese, combining general knowledge with research findings."""
224
 
225
  try:
226
  # T5 expects a specific format for the input
 
234
  outputs = model.generate(
235
  **inputs,
236
  max_length=max_length,
237
+ min_length=200,
238
  num_beams=5,
239
  length_penalty=1.5,
240
  temperature=0.7,
 
251
 
252
  # If response is too short or empty, provide a general overview
253
  if len(response.strip()) < 100:
254
+ return """### CONHECIMENTO GERAL ###
255
+ O Transtorno do Espectro do Autismo (TEA) é uma condição do neurodesenvolvimento que afeta a forma como uma pessoa percebe e interage com o mundo. O TEA engloba diferentes condições anteriormente separadas, incluindo:
256
+ - Autismo Infantil Precoce
257
+ - Autismo de Kanner
258
+ - Autismo de Alto Funcionamento
259
+ - Síndrome de Asperger
260
+ - Transtorno Global do Desenvolvimento sem outra especificação
261
 
262
+ Características principais:
263
+ 1. Comunicação e interação social
264
+ 2. Padrões repetitivos de comportamento
265
+ 3. Interesses específicos e intensos
266
+ 4. Sensibilidade sensorial
267
 
268
+ ### PESQUISAS RECENTES ###
269
+ As pesquisas atuais não forneceram informações específicas sobre este aspecto do autismo. Para obter informações baseadas em pesquisas recentes, tente fazer uma pergunta mais específica sobre:
270
+ - Causas genéticas e ambientais
271
+ - Métodos de intervenção precoce
272
+ - Tratamentos e terapias
273
+ - Desenvolvimento neurológico"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
 
275
  # Format the response for better readability
276
  formatted_response = response.replace(". ", ".\n").replace("• ", "\n• ")