Spaces:
Sleeping
Sleeping
fix: prompt
Browse files
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"""
|
212 |
|
213 |
Question: {clean_question}
|
214 |
|
215 |
-
Research
|
216 |
{clean_context}
|
217 |
|
218 |
-
Instructions:
|
219 |
-
1.
|
220 |
-
2.
|
221 |
-
3.
|
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=
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
|
263 |
-
|
264 |
-
|
265 |
-
-
|
266 |
-
-
|
267 |
-
-
|
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• ")
|