robert 2.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robert/__init__.py +9 -0
- robert/__main__.py +20 -0
- robert/_version.py +3 -0
- robert/api.py +646 -0
- robert/aqme.py +280 -0
- robert/argument_parser.py +98 -0
- robert/checkml.py +433 -0
- robert/checkml_score.py +50 -0
- robert/curate.py +217 -0
- robert/evaluate_bot_retrieval.py +125 -0
- robert/evaluate_bot_support.py +102 -0
- robert/evaluate_workflow_summaries.py +87 -0
- robert/export_bot_docs_knowledge.py +1632 -0
- robert/generate.py +249 -0
- robert/generate_utils.py +311 -0
- robert/gui_easyrob/__init__.py +0 -0
- robert/gui_easyrob/assets/gif_easyrob.gif +0 -0
- robert/gui_easyrob/bot/__init__.py +47 -0
- robert/gui_easyrob/bot/answer_metadata.py +198 -0
- robert/gui_easyrob/bot/bot_context.py +679 -0
- robert/gui_easyrob/bot/bot_engine.py +1100 -0
- robert/gui_easyrob/bot/bot_panel.py +1231 -0
- robert/gui_easyrob/bot/bot_rag.py +1178 -0
- robert/gui_easyrob/bot/bot_window.py +39 -0
- robert/gui_easyrob/bot/bot_worker.py +149 -0
- robert/gui_easyrob/bot/credential_store.py +143 -0
- robert/gui_easyrob/bot/error_parser.py +105 -0
- robert/gui_easyrob/bot/evidence_policy.py +164 -0
- robert/gui_easyrob/bot/heuristics.py +859 -0
- robert/gui_easyrob/bot/icons.py +56 -0
- robert/gui_easyrob/bot/input_csv_audit.py +212 -0
- robert/gui_easyrob/bot/knowledge/aqme_context.json +5907 -0
- robert/gui_easyrob/bot/knowledge/robert_context.json +4817 -0
- robert/gui_easyrob/bot/knowledge/ui_context.json +8293 -0
- robert/gui_easyrob/bot/knowledge_schema.py +1252 -0
- robert/gui_easyrob/bot/knowledge_sources/aqme_user_guidance.json +442 -0
- robert/gui_easyrob/bot/knowledge_sources/coverage_manifest.json +95 -0
- robert/gui_easyrob/bot/knowledge_sources/robert_user_guidance.json +471 -0
- robert/gui_easyrob/bot/knowledge_sources/ui_user_guidance.json +1312 -0
- robert/gui_easyrob/bot/llm_providers.py +1573 -0
- robert/gui_easyrob/bot/online_docs.py +105 -0
- robert/gui_easyrob/bot/prompt_policy.py +575 -0
- robert/gui_easyrob/bot/question_intent.py +562 -0
- robert/gui_easyrob/bot/response_quality.py +104 -0
- robert/gui_easyrob/bot/result_insights.py +225 -0
- robert/gui_easyrob/bot/token_usage.py +75 -0
- robert/gui_easyrob/bot/workflow_results.py +1396 -0
- robert/gui_easyrob/checkml_launcher.py +15 -0
- robert/gui_easyrob/easyrob.py +29 -0
- robert/gui_easyrob/easyrob_launcher.py +113 -0
- robert/gui_easyrob/main/__init__.py +9 -0
- robert/gui_easyrob/main/window.py +5152 -0
- robert/gui_easyrob/result_navigation.py +14 -0
- robert/gui_easyrob/tabs/__init__.py +23 -0
- robert/gui_easyrob/tabs/advanced_options.py +370 -0
- robert/gui_easyrob/tabs/aqme.py +1234 -0
- robert/gui_easyrob/tabs/checkml.py +898 -0
- robert/gui_easyrob/tabs/images.py +427 -0
- robert/gui_easyrob/tabs/interactive_predictions.py +555 -0
- robert/gui_easyrob/tabs/molssi.py +447 -0
- robert/gui_easyrob/tabs/predictions.py +484 -0
- robert/gui_easyrob/tabs/result_catalog.py +170 -0
- robert/gui_easyrob/tabs/results.py +490 -0
- robert/gui_easyrob/tabs/results_workspace.py +120 -0
- robert/gui_easyrob/test_bot_input_csv_audit.py +152 -0
- robert/gui_easyrob/test_bot_question_routing.py +383 -0
- robert/gui_easyrob/test_bot_result_analysis.py +356 -0
- robert/gui_easyrob/test_bot_retrieval_evaluation.py +110 -0
- robert/gui_easyrob/test_bot_ui_integration.py +278 -0
- robert/gui_easyrob/test_checkml_app_mode.py +124 -0
- robert/gui_easyrob/test_checkml_completion.py +57 -0
- robert/gui_easyrob/test_checkml_defaults.py +37 -0
- robert/gui_easyrob/test_checkml_result_summary.py +113 -0
- robert/gui_easyrob/test_checkml_web_mode.py +57 -0
- robert/gui_easyrob/test_dialog_layout.py +33 -0
- robert/gui_easyrob/test_gui_bot_regressions.py +320 -0
- robert/gui_easyrob/test_molssi_auto.py +569 -0
- robert/gui_easyrob/test_tutorial_view.py +215 -0
- robert/gui_easyrob/tutorials/check_model.md +25 -0
- robert/gui_easyrob/tutorials/chemdraw.md +49 -0
- robert/gui_easyrob/tutorials/csv.md +53 -0
- robert/gui_easyrob/tutorials/descriptors.md +21 -0
- robert/gui_easyrob/tutorials/overview.md +65 -0
- robert/gui_easyrob/tutorials/predictions.md +25 -0
- robert/gui_easyrob/tutorials/robbot.md +29 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_10.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_11.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_12.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_13.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_8.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_9.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_8.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_9.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_8.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_1_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_8.png +0 -0
- robert/gui_easyrob/utils/__init__.py +0 -0
- robert/gui_easyrob/utils/aqme_utils.py +238 -0
- robert/gui_easyrob/utils/molssi_utils.py +584 -0
- robert/gui_easyrob/utils/predictions_utils.py +985 -0
- robert/gui_easyrob/utils/utils_gui.py +738 -0
- robert/gui_easyrob/version.py +68 -0
- robert/gui_easyrob/web/app.css +484 -0
- robert/gui_easyrob/web/app.html +134 -0
- robert/gui_easyrob/web/app.js +764 -0
- robert/gui_easyrob/web/checkml_brand.png +0 -0
- robert/gui_easyrob/web/easyrob_background.gif +0 -0
- robert/gui_easyrob/web/easyrob_background.png +0 -0
- robert/gui_easyrob/web/images.css +89 -0
- robert/gui_easyrob/web/images.html +39 -0
- robert/gui_easyrob/web/images.js +101 -0
- robert/gui_easyrob/web/results.js +499 -0
- robert/gui_easyrob/web/robert_brand.png +0 -0
- robert/gui_easyrob/web_dialogs.py +64 -0
- robert/gui_easyrob/web_results.py +253 -0
- robert/gui_easyrob/web_shell.py +684 -0
- robert/gui_easyrob/workflow_progress.py +89 -0
- robert/gui_easyrob/workflow_run_lock.py +27 -0
- robert/icons/CheckML_icon.png +0 -0
- robert/icons/Robert_icon.png +0 -0
- robert/icons/Robert_logo.jpg +0 -0
- robert/icons/Robert_logo_transparent.png +0 -0
- robert/icons/documentation_icon.png +0 -0
- robert/icons/info_icon.png +0 -0
- robert/icons/pdf_icon.png +0 -0
- robert/icons/play_icon.png +0 -0
- robert/icons/stop_icon.png +0 -0
- robert/icons/youtube_icon.ico +0 -0
- robert/predict.py +193 -0
- robert/predict_utils.py +410 -0
- robert/report/CheckML_logo.jpg +0 -0
- robert/report/GENERATE.png +0 -0
- robert/report/Robert_icon.ico +0 -0
- robert/report/Robert_logo.jpg +0 -0
- robert/report/Robert_logo1.jpg +0 -0
- robert/report/abbrev.png +0 -0
- robert/report/adv_anal.png +0 -0
- robert/report/checkml_pass.svg +3 -0
- robert/report/checkml_unclear.svg +3 -0
- robert/report/checkml_warning.svg +3 -0
- robert/report/features.png +0 -0
- robert/report/outliers.png +0 -0
- robert/report/pred.png +0 -0
- robert/report/repro.png +0 -0
- robert/report/robust_x.png +0 -0
- robert/report/robust_y_high.png +0 -0
- robert/report/robust_y_low.png +0 -0
- robert/report/score.png +0 -0
- robert/report/score_0.jpg +0 -0
- robert/report/score_1.jpg +0 -0
- robert/report/score_10.jpg +0 -0
- robert/report/score_2.jpg +0 -0
- robert/report/score_3.jpg +0 -0
- robert/report/score_4.jpg +0 -0
- robert/report/score_5.jpg +0 -0
- robert/report/score_6.jpg +0 -0
- robert/report/score_7.jpg +0 -0
- robert/report/score_8.jpg +0 -0
- robert/report/score_9.jpg +0 -0
- robert/report/score_gray_0.jpg +0 -0
- robert/report/score_gray_1.jpg +0 -0
- robert/report/score_gray_10.jpg +0 -0
- robert/report/score_gray_2.jpg +0 -0
- robert/report/score_gray_3.jpg +0 -0
- robert/report/score_gray_4.jpg +0 -0
- robert/report/score_gray_5.jpg +0 -0
- robert/report/score_gray_6.jpg +0 -0
- robert/report/score_gray_7.jpg +0 -0
- robert/report/score_gray_8.jpg +0 -0
- robert/report/score_gray_9.jpg +0 -0
- robert/report/score_w_1_0.jpg +0 -0
- robert/report/score_w_1_1.jpg +0 -0
- robert/report/score_w_2_0.jpg +0 -0
- robert/report/score_w_2_1.jpg +0 -0
- robert/report/score_w_2_2.jpg +0 -0
- robert/report/score_w_2_gray_0.jpg +0 -0
- robert/report/score_w_2_gray_1.jpg +0 -0
- robert/report/score_w_2_gray_2.jpg +0 -0
- robert/report/score_w_3_0.jpg +0 -0
- robert/report/score_w_3_1.jpg +0 -0
- robert/report/score_w_3_2.jpg +0 -0
- robert/report/score_w_3_3.jpg +0 -0
- robert/report/score_w_4_0.jpg +0 -0
- robert/report/score_w_4_1.JPG +0 -0
- robert/report/score_w_4_2.jpg +0 -0
- robert/report/score_w_4_3.jpg +0 -0
- robert/report/score_w_4_4.jpg +0 -0
- robert/report/transpa.png +0 -0
- robert/report/y_distrib.png +0 -0
- robert/report.py +2880 -0
- robert/report_utils.py +2270 -0
- robert/robert.py +181 -0
- robert/utils.py +4763 -0
- robert/verify.py +606 -0
- robert-2.2.0.dist-info/METADATA +55 -0
- robert-2.2.0.dist-info/RECORD +261 -0
- robert-2.2.0.dist-info/WHEEL +5 -0
- robert-2.2.0.dist-info/entry_points.txt +3 -0
- robert-2.2.0.dist-info/licenses/LICENSE +21 -0
- robert-2.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
"""Question intent classification for the EasyROB bot."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
import unicodedata
|
|
7
|
+
from typing import Mapping, Sequence
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"classify_question_intent",
|
|
11
|
+
"is_gui_question",
|
|
12
|
+
"is_explicit_web_request",
|
|
13
|
+
"is_generic_question",
|
|
14
|
+
"is_follow_up_question",
|
|
15
|
+
"is_workflow_result_question",
|
|
16
|
+
"requires_fresh_information",
|
|
17
|
+
"select_inference_history",
|
|
18
|
+
"last_completed_exchange",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
_TOKEN_RE = re.compile(r"[a-z0-9_]+")
|
|
23
|
+
|
|
24
|
+
_DIAGNOSTIC_PHRASES = (
|
|
25
|
+
"why is",
|
|
26
|
+
"why are",
|
|
27
|
+
"why can",
|
|
28
|
+
"why can't",
|
|
29
|
+
"cannot run",
|
|
30
|
+
"can't run",
|
|
31
|
+
"not working",
|
|
32
|
+
"doesn't work",
|
|
33
|
+
"disabled",
|
|
34
|
+
"blocked",
|
|
35
|
+
"error",
|
|
36
|
+
"failed",
|
|
37
|
+
"failure",
|
|
38
|
+
"warning",
|
|
39
|
+
"not found",
|
|
40
|
+
"locked",
|
|
41
|
+
"por que",
|
|
42
|
+
"no funciona",
|
|
43
|
+
"deshabilitad",
|
|
44
|
+
"bloquead",
|
|
45
|
+
"fallo",
|
|
46
|
+
"advertencia",
|
|
47
|
+
)
|
|
48
|
+
_TUTORIAL_PHRASES = (
|
|
49
|
+
"how do i",
|
|
50
|
+
"how can i",
|
|
51
|
+
"how to",
|
|
52
|
+
"what do i need",
|
|
53
|
+
"which parameters",
|
|
54
|
+
"what parameters",
|
|
55
|
+
"how it works",
|
|
56
|
+
"how does",
|
|
57
|
+
"what is",
|
|
58
|
+
"where can i",
|
|
59
|
+
"what should i do next",
|
|
60
|
+
)
|
|
61
|
+
_RESULTS_TERMS = {
|
|
62
|
+
"resultado", "resultados", "informe", "informes", "metrica", "metricas",
|
|
63
|
+
"prediccion", "predicciones", "puntuacion", "puntuaciones",
|
|
64
|
+
"result",
|
|
65
|
+
"results",
|
|
66
|
+
"metric",
|
|
67
|
+
"metrics",
|
|
68
|
+
"rmse",
|
|
69
|
+
"mae",
|
|
70
|
+
"r2",
|
|
71
|
+
"squared",
|
|
72
|
+
"accuracy",
|
|
73
|
+
"score",
|
|
74
|
+
"scores",
|
|
75
|
+
"report",
|
|
76
|
+
"reports",
|
|
77
|
+
"prediction",
|
|
78
|
+
"predictions",
|
|
79
|
+
"no_pfi",
|
|
80
|
+
"interpret",
|
|
81
|
+
"interpretation",
|
|
82
|
+
"model",
|
|
83
|
+
"models",
|
|
84
|
+
}
|
|
85
|
+
_METRIC_TERMS = {
|
|
86
|
+
"rmse",
|
|
87
|
+
"mae",
|
|
88
|
+
"r2",
|
|
89
|
+
"accuracy",
|
|
90
|
+
"score",
|
|
91
|
+
"scores",
|
|
92
|
+
"metric",
|
|
93
|
+
"metrics",
|
|
94
|
+
}
|
|
95
|
+
_PARAMETER_TERMS = {
|
|
96
|
+
"parameter",
|
|
97
|
+
"parameters",
|
|
98
|
+
"option",
|
|
99
|
+
"options",
|
|
100
|
+
"threshold",
|
|
101
|
+
"cutoff",
|
|
102
|
+
"setting",
|
|
103
|
+
"settings",
|
|
104
|
+
"pfi",
|
|
105
|
+
}
|
|
106
|
+
_MODULE_TERMS = {
|
|
107
|
+
"generate",
|
|
108
|
+
"curate",
|
|
109
|
+
"predict",
|
|
110
|
+
"verify",
|
|
111
|
+
"qdescp",
|
|
112
|
+
"csearch",
|
|
113
|
+
"cmin",
|
|
114
|
+
"qcorr",
|
|
115
|
+
"qprep",
|
|
116
|
+
}
|
|
117
|
+
_NAMED_SUBJECTS = _MODULE_TERMS | _METRIC_TERMS | {"aqme", "robert", "pfi", "shap"}
|
|
118
|
+
_TUTORIAL_TERMS = {
|
|
119
|
+
"how",
|
|
120
|
+
"use",
|
|
121
|
+
"using",
|
|
122
|
+
"start",
|
|
123
|
+
"setup",
|
|
124
|
+
"configure",
|
|
125
|
+
"parameter",
|
|
126
|
+
"parameters",
|
|
127
|
+
"option",
|
|
128
|
+
"options",
|
|
129
|
+
"need",
|
|
130
|
+
"before",
|
|
131
|
+
"workflow",
|
|
132
|
+
"works",
|
|
133
|
+
}
|
|
134
|
+
_FOLLOW_UP_TERMS = {
|
|
135
|
+
"it",
|
|
136
|
+
"that",
|
|
137
|
+
"this",
|
|
138
|
+
"those",
|
|
139
|
+
"these",
|
|
140
|
+
"them",
|
|
141
|
+
"there",
|
|
142
|
+
"and",
|
|
143
|
+
"also",
|
|
144
|
+
"then",
|
|
145
|
+
"enabled",
|
|
146
|
+
"disabled",
|
|
147
|
+
"tab",
|
|
148
|
+
}
|
|
149
|
+
_FOLLOW_UP_PHRASES = (
|
|
150
|
+
"what should i check next",
|
|
151
|
+
"what do i check next",
|
|
152
|
+
"what next",
|
|
153
|
+
"next step",
|
|
154
|
+
"explicamelo",
|
|
155
|
+
"explicalo",
|
|
156
|
+
"explicarlo mas",
|
|
157
|
+
"mas detalle",
|
|
158
|
+
"more detail",
|
|
159
|
+
)
|
|
160
|
+
_OPAQUE_FOLLOW_UPS = {
|
|
161
|
+
"what",
|
|
162
|
+
"what?",
|
|
163
|
+
"excuse me",
|
|
164
|
+
"excuse me?",
|
|
165
|
+
"sorry",
|
|
166
|
+
"sorry?",
|
|
167
|
+
"huh",
|
|
168
|
+
"huh?",
|
|
169
|
+
"why",
|
|
170
|
+
"why?",
|
|
171
|
+
"por que",
|
|
172
|
+
"por que?",
|
|
173
|
+
"como",
|
|
174
|
+
"como?",
|
|
175
|
+
}
|
|
176
|
+
_LIVE_CONTEXT_HINT_RE = re.compile(
|
|
177
|
+
r"\b(current|currently|here|now|just|popup|dialog|warning|message|alert|error|failed|failure|blocked|disabled|loaded|selected|shown|displayed|this|that|these|it|my|missing|overlap|ahora|actualmente|aqui|pestana|deshabilitada|deshabilitado|bloqueada|bloqueado|cargada|cargado|seleccionada|seleccionado|mi|mis|este|esta|estos|estas|falta|faltan|ausente|ausentes|solapamiento)\b",
|
|
178
|
+
re.IGNORECASE,
|
|
179
|
+
)
|
|
180
|
+
_GENERIC_TOPIC_HINT_RE = re.compile(
|
|
181
|
+
r"\b(?:aqme|robert|descriptors?|descriptores?|features?|machine learning|models?|modelos?|"
|
|
182
|
+
r"molecules?|predictions?|predicciones?|concept|meaning|difference|rmse|mae|r2|accuracy|"
|
|
183
|
+
r"metrics?|metricas?|pfi|no_pfi|shap|overfitting|cross[- ]validation|regression|classification)\b",
|
|
184
|
+
)
|
|
185
|
+
_EXPLANATION_RE = re.compile(
|
|
186
|
+
r"^(?:(?:and|y)\s+)?(?:what (?:is|are|does|do)\b|what['’]s\b|what .+ means?\b|"
|
|
187
|
+
r"how (?:does|do|to)\b|how many .+ (?:does|do)\b|why (?:does|do|is|are)\b|"
|
|
188
|
+
r"(?:can you )?(?:explain|define)\b|que (?:es|son|significa|hace|hacen|muestra)\b|"
|
|
189
|
+
r"como (?:funciona|funcionan)\b|"
|
|
190
|
+
r"(?:puedes )?explic(?:a|ar|ame)\b|define\b|difference between\b|(?:que )?diferencia (?:hay )?entre\b)",
|
|
191
|
+
)
|
|
192
|
+
_GUI_CONTROL_RE = re.compile(
|
|
193
|
+
r"\b(?:buttons?|tabs?|pop[- ]?ups?|dialogs?|checkbox(?:es)?|drop[- ]?downs?|toggles?|"
|
|
194
|
+
r"message box|boton(?:es)?|pestanas?|ventanas?|dialogos?|casillas?|desplegables?)\b|"
|
|
195
|
+
r"\b(?:views?|vistas?)\s+(?:is\s+|esta\s+)?(?:enabled|disabled|available|unavailable|"
|
|
196
|
+
r"habilitada|deshabilitada|disponible)\b",
|
|
197
|
+
)
|
|
198
|
+
_GUI_MESSAGE_RE = re.compile(
|
|
199
|
+
r"\b(?:this|that|the|este|esta|ese|esa)\s+(?:warning|error|alert|message|advertencia|aviso|mensaje)\b|"
|
|
200
|
+
r"\b(?:warning|error|alert|message|advertencia|aviso|mensaje)\s+(?:on screen|displayed|en pantalla)\b",
|
|
201
|
+
)
|
|
202
|
+
_GUI_PROCEDURE_RE = re.compile(
|
|
203
|
+
r"^(?:(?:how (?:do|can|should) i|how to|where (?:do|can) i)\s+"
|
|
204
|
+
r"(?:run|start|load|open|find|view|configure|set|activate|enable|export|save|train)\b|"
|
|
205
|
+
r"(?:como|donde)\s+(?:ejecut\w+|inici\w+|carg\w+|abr\w+|encuentr\w+|ver|"
|
|
206
|
+
r"configur\w+|activ\w+|export\w+|guard\w+|entren\w+)\b)",
|
|
207
|
+
)
|
|
208
|
+
_SUMMARY_COMMAND_RE = re.compile(
|
|
209
|
+
r"^(?:(?:please|por favor)[, ]+)?(?:summari[sz]e|resumen|resume|resumir)"
|
|
210
|
+
r"(?:[ .?!]*$|\s+(?:(?:my|our|the|this|el|los|mi|mis|este)\s+)?"
|
|
211
|
+
r"(?:(?:robert|aqme)\s+)?(?:results?|resultados?|reports?|informes?|run|"
|
|
212
|
+
r"ejecucion|workflow|flujo|all models|todos los modelos)\b)",
|
|
213
|
+
)
|
|
214
|
+
_RESULT_SUBJECT_RE = re.compile(
|
|
215
|
+
r"\b(?:results?|resultados?|reports?|informes?|metrics?|metricas?|rmse|mae|r2|r\^2|"
|
|
216
|
+
r"roc[- _]?auc|auc|accuracy|f1|mcc|scores?|puntuaciones?|test|validation|validacion|"
|
|
217
|
+
r"predictions?|predicciones?|outliers?|warnings?|advertencias?|avisos?|errores?|"
|
|
218
|
+
r"shap|pfi|no_pfi|features?|importance|importancia|descriptors?|descriptores?|"
|
|
219
|
+
r"uncertaint(?:y|ies)|incertidumbres?|overlap|solapamiento|leakage|"
|
|
220
|
+
r"outputs?|salidas?|files?|archivos?|curate|generate|verify|predict|aqme|qdescp|csearch|robert|"
|
|
221
|
+
r"workflow|flujo|run|ejecucion|models?|modelos?|solvent|disolvente|solvente)\b",
|
|
222
|
+
)
|
|
223
|
+
_RUN_REFERENCE_RE = re.compile(
|
|
224
|
+
r"\b(?:my|our|this|the last|mi|mis|nuestros?|esta|este|ultima|ultimo)\s+"
|
|
225
|
+
r"(?:robert\s+|aqme\s+)?(?:results?|resultados?|run|ejecucion|workflow|flujo|reports?|informes?|"
|
|
226
|
+
r"predictions?|predicciones?|metrics?|metricas?|rmse|mae|r2|score|puntuacion|pfi|shap|csvs?)\b|"
|
|
227
|
+
r"\b(?:in|from|of|en|del)\s+(?:the|el|los)\s+(?:results?|resultados?|run|reports?|informes?)\b",
|
|
228
|
+
)
|
|
229
|
+
_RUN_OUTCOME_RE = re.compile(
|
|
230
|
+
r"\b(?:did|was|were|passed|failed|finished|completed|happened|generated|produced|created|"
|
|
231
|
+
r"obtained|recorded|fue|fueron|dio|dieron|paso|aprobo|fallo|termino|ocurrio|se ejecuto|"
|
|
232
|
+
r"generad[oa]s?|genero|generaron|produjo|cread[oa]s?|obtuve|obtuvimos)\b",
|
|
233
|
+
)
|
|
234
|
+
_RESULT_REQUEST_RE = re.compile(
|
|
235
|
+
r"\b(?:show|compare|interpret|analy[sz]e|muestra|muestran|compara|interpreta|analiza|"
|
|
236
|
+
r"faltan|missing|best|mejores?)\b",
|
|
237
|
+
)
|
|
238
|
+
_FOCUSED_RESULT_RE = re.compile(
|
|
239
|
+
r"\b(?:shap|pfi|no_pfi|rmse|mae|r2)\s+(?:for|para)\s+[a-z0-9_]{2,4}\s*[?.!]*$|"
|
|
240
|
+
r"\b(?:test|train|validation|validacion)\s+(?:rmse|mae|r2|accuracy|f1|mcc|score)\b|"
|
|
241
|
+
r"\b(?:the|los|el)\s+(?:results?|resultados?|metrics?|metricas?|best model|mejor modelo)\s*[?.!]*$",
|
|
242
|
+
)
|
|
243
|
+
_OPERATIONAL_HINT_RE = re.compile(
|
|
244
|
+
r"\b(where|file|folder|path|project|csv|smiles|load|open|select|enable|disable|run|click|button|tab|start|configure|set|archivo|carpeta|ruta|proyecto|cargar|abrir|seleccionar|activar|desactivar|ejecutar|pulsar|boton|pestana|configurar)\b",
|
|
245
|
+
re.IGNORECASE,
|
|
246
|
+
)
|
|
247
|
+
_GREETING_TERMS = {
|
|
248
|
+
"hi",
|
|
249
|
+
"hello",
|
|
250
|
+
"hey",
|
|
251
|
+
"heyy",
|
|
252
|
+
"ey",
|
|
253
|
+
"yo",
|
|
254
|
+
"hola",
|
|
255
|
+
"buenas",
|
|
256
|
+
"hello!",
|
|
257
|
+
"hi!",
|
|
258
|
+
"hey!",
|
|
259
|
+
}
|
|
260
|
+
_GREETING_PHRASES = (
|
|
261
|
+
"how are you",
|
|
262
|
+
"how are u",
|
|
263
|
+
"how ar eu",
|
|
264
|
+
"how r u",
|
|
265
|
+
"how's it going",
|
|
266
|
+
"how is it going",
|
|
267
|
+
)
|
|
268
|
+
_GREETING_PHRASE_TERMS = _GREETING_TERMS | {
|
|
269
|
+
"how", "are", "you", "u", "ar", "eu", "doing", "today", "is", "it", "going", "s",
|
|
270
|
+
}
|
|
271
|
+
_EXPLICIT_WEB_RE = re.compile(
|
|
272
|
+
r"\b(?:search|look up|browse|buscar|busca|consulta)\b.*\b(?:web|internet|online|en linea)\b",
|
|
273
|
+
re.IGNORECASE,
|
|
274
|
+
)
|
|
275
|
+
_FRESH_INFORMATION_RE = re.compile(
|
|
276
|
+
r"\b(?:latest|newest|recent|today|this week|this month|currently available|"
|
|
277
|
+
r"current (?:[a-z0-9_.-]+ ){0,3}(?:version|release|documentation|docs|price|status|recommendation)|"
|
|
278
|
+
r"ultima version|última versión|mas reciente|más reciente|hoy|esta semana|actualmente disponible)\b",
|
|
279
|
+
re.IGNORECASE,
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def _normalize_text(value: object) -> str:
|
|
284
|
+
normalized = unicodedata.normalize("NFKD", str(value or ""))
|
|
285
|
+
normalized = "".join(character for character in normalized if not unicodedata.combining(character))
|
|
286
|
+
return " ".join(normalized.casefold().split())
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def _tokenize(value: str) -> set[str]:
|
|
290
|
+
return set(_TOKEN_RE.findall(_normalize_text(value)))
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def _last_user_message(conversation_history: Sequence[Mapping[str, str]] | None) -> str:
|
|
294
|
+
if not conversation_history:
|
|
295
|
+
return ""
|
|
296
|
+
for message in reversed(conversation_history):
|
|
297
|
+
if str(message.get("role", "")).strip().lower() != "user":
|
|
298
|
+
continue
|
|
299
|
+
content = str(message.get("content", "")).strip()
|
|
300
|
+
if content:
|
|
301
|
+
return content
|
|
302
|
+
return ""
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def _looks_like_follow_up(question: str, tokens: set[str]) -> bool:
|
|
306
|
+
if not tokens:
|
|
307
|
+
return False
|
|
308
|
+
named_subject = re.match(
|
|
309
|
+
r"^(?:and|y) (?:what (?:does|do|is|are)|how (?:does|do)|"
|
|
310
|
+
r"que (?:hace|es|son)|como funciona) ([a-z0-9_]+)\b",
|
|
311
|
+
question,
|
|
312
|
+
)
|
|
313
|
+
if named_subject and named_subject.group(1) in _NAMED_SUBJECTS | {"a", "an", "un", "una"}:
|
|
314
|
+
return False
|
|
315
|
+
if any(phrase in question for phrase in _FOLLOW_UP_PHRASES):
|
|
316
|
+
return True
|
|
317
|
+
if not tokens & {"rmse", "mae", "r2", "accuracy", "mcc", "f1", "auc"} and re.search(
|
|
318
|
+
r"\b(?:lower|higher|better|worse)\b.*\b(?:value|score|number)\b|"
|
|
319
|
+
r"\b(?:value|score|number)\b.*\b(?:lower|higher|better|worse)\b",
|
|
320
|
+
question,
|
|
321
|
+
):
|
|
322
|
+
return True
|
|
323
|
+
if tokens & {"each", "either"} and tokens & {"use", "choose"}:
|
|
324
|
+
return True
|
|
325
|
+
if len(tokens) <= 8 and tokens & {
|
|
326
|
+
"it", "that", "this", "those", "these", "them",
|
|
327
|
+
"eso", "esto", "esos", "estos", "esas", "estas",
|
|
328
|
+
}:
|
|
329
|
+
return True
|
|
330
|
+
if re.search(r"\b(?:como|donde) (?:lo|la|los|las)\b", question):
|
|
331
|
+
return True
|
|
332
|
+
if question.startswith(("y ", "entonces ", "and ", "what about ", "what if ")):
|
|
333
|
+
return True
|
|
334
|
+
if question.startswith(("what is ", "what are ", "how does ", "how do i ", "how can i ", "which ", "where ")):
|
|
335
|
+
return False
|
|
336
|
+
if len(tokens) <= 5 and tokens & _FOLLOW_UP_TERMS:
|
|
337
|
+
return True
|
|
338
|
+
return question.startswith(("and ", "what about ", "what if ", "it ", "that "))
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def is_follow_up_question(question: str) -> bool:
|
|
342
|
+
"""Return whether *question* conservatively depends on prior conversation."""
|
|
343
|
+
|
|
344
|
+
clean_question = _normalize_text(question).lstrip("¿¡")
|
|
345
|
+
return clean_question in _OPAQUE_FOLLOW_UPS or _looks_like_follow_up(
|
|
346
|
+
clean_question, _tokenize(clean_question)
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def is_explicit_web_request(question: str) -> bool:
|
|
351
|
+
"""Return whether the user explicitly requested an online lookup."""
|
|
352
|
+
return type(question) is str and bool(_EXPLICIT_WEB_RE.search(question))
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def requires_fresh_information(question: str) -> bool:
|
|
356
|
+
"""Return whether a question depends on time-sensitive external facts."""
|
|
357
|
+
return type(question) is str and bool(_FRESH_INFORMATION_RE.search(question))
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def is_gui_question(question: str) -> bool:
|
|
361
|
+
"""Identify requests about interactive controls or an on-screen message."""
|
|
362
|
+
text = _normalize_text(question).lstrip("¿¡")
|
|
363
|
+
return bool(_GUI_CONTROL_RE.search(text) or _GUI_PROCEDURE_RE.search(text) or (
|
|
364
|
+
_GUI_MESSAGE_RE.search(text) and not _RUN_REFERENCE_RE.search(text)
|
|
365
|
+
))
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
def is_workflow_result_question(
|
|
369
|
+
question: str,
|
|
370
|
+
intent: str | None = None,
|
|
371
|
+
*,
|
|
372
|
+
named_model: bool = False,
|
|
373
|
+
) -> bool:
|
|
374
|
+
"""Identify questions that depend on a particular workflow execution."""
|
|
375
|
+
text = _normalize_text(question).lstrip("¿¡")
|
|
376
|
+
if _SUMMARY_COMMAND_RE.match(text):
|
|
377
|
+
return True
|
|
378
|
+
if not text or is_gui_question(text):
|
|
379
|
+
return False
|
|
380
|
+
if _RUN_REFERENCE_RE.search(text) or re.search(r"\b(?:what happened|que ocurrio|que paso)\b", text):
|
|
381
|
+
return True
|
|
382
|
+
result_subject = bool(_RESULT_SUBJECT_RE.search(text))
|
|
383
|
+
if _FOCUSED_RESULT_RE.search(text) or (result_subject and named_model):
|
|
384
|
+
return True
|
|
385
|
+
if _EXPLANATION_RE.match(text):
|
|
386
|
+
return False
|
|
387
|
+
if _RUN_OUTCOME_RE.search(text):
|
|
388
|
+
return result_subject
|
|
389
|
+
return (intent or classify_question_intent(text)) == "results" or (
|
|
390
|
+
result_subject and bool(_RESULT_REQUEST_RE.search(text))
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def is_generic_question(
|
|
395
|
+
question: str,
|
|
396
|
+
intent: str | None = None,
|
|
397
|
+
*,
|
|
398
|
+
conversation_history: Sequence[Mapping[str, str]] | None = None,
|
|
399
|
+
) -> bool:
|
|
400
|
+
"""Return whether a self-contained explanation should omit live GUI context."""
|
|
401
|
+
if type(question) is not str:
|
|
402
|
+
return False
|
|
403
|
+
clean_question = _normalize_text(question).lstrip("¿¡")
|
|
404
|
+
resolved_intent = (
|
|
405
|
+
str(intent or "").strip().lower()
|
|
406
|
+
or classify_question_intent(clean_question)
|
|
407
|
+
)
|
|
408
|
+
if is_gui_question(clean_question) or is_workflow_result_question(clean_question, resolved_intent):
|
|
409
|
+
return False
|
|
410
|
+
if any(marker in clean_question for marker in ("<", ">", "\x00")):
|
|
411
|
+
return False
|
|
412
|
+
if is_follow_up_question(clean_question):
|
|
413
|
+
previous = _last_user_message(conversation_history)
|
|
414
|
+
return bool(previous and is_generic_question(previous))
|
|
415
|
+
if _LIVE_CONTEXT_HINT_RE.search(clean_question):
|
|
416
|
+
return False
|
|
417
|
+
if _OPERATIONAL_HINT_RE.search(clean_question):
|
|
418
|
+
return False
|
|
419
|
+
return bool(_EXPLANATION_RE.match(clean_question) or _GENERIC_TOPIC_HINT_RE.search(clean_question))
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
def _canonical_history_record(record: object) -> dict[str, str] | None:
|
|
423
|
+
if not isinstance(record, Mapping):
|
|
424
|
+
return None
|
|
425
|
+
role = record.get("role")
|
|
426
|
+
content = record.get("content")
|
|
427
|
+
if not isinstance(role, str) or role not in {"user", "assistant"} or not isinstance(content, str):
|
|
428
|
+
return None
|
|
429
|
+
clean_content = content.strip()
|
|
430
|
+
if not clean_content or record.get("memory_eligible", True) is not True:
|
|
431
|
+
return None
|
|
432
|
+
return {"role": role, "content": clean_content}
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def select_inference_history(
|
|
436
|
+
question: str,
|
|
437
|
+
conversation_history: Sequence[Mapping[str, object]] | None,
|
|
438
|
+
) -> tuple[dict[str, str], ...]:
|
|
439
|
+
"""Return the nearest complete standalone exchange behind a follow-up chain."""
|
|
440
|
+
|
|
441
|
+
if not is_follow_up_question(question):
|
|
442
|
+
return ()
|
|
443
|
+
records = tuple(conversation_history) if isinstance(conversation_history, (list, tuple)) else ()
|
|
444
|
+
selected = last_completed_exchange(records)
|
|
445
|
+
while (selected and len(records) >= 4
|
|
446
|
+
and _canonical_history_record(records[-2]) == selected[0]
|
|
447
|
+
and _canonical_history_record(records[-1]) == selected[1]
|
|
448
|
+
and is_follow_up_question(selected[0]["content"])):
|
|
449
|
+
previous_records = records[:-2]
|
|
450
|
+
previous = last_completed_exchange(previous_records)
|
|
451
|
+
if (not previous or _canonical_history_record(previous_records[-2]) != previous[0]
|
|
452
|
+
or _canonical_history_record(previous_records[-1]) != previous[1]):
|
|
453
|
+
break
|
|
454
|
+
selected = previous
|
|
455
|
+
records = previous_records
|
|
456
|
+
return selected
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
def last_completed_exchange(
|
|
460
|
+
conversation_history: Sequence[Mapping[str, object]] | None,
|
|
461
|
+
) -> tuple[dict[str, str], ...]:
|
|
462
|
+
"""Select adjacent eligible turns without joining across invalid records."""
|
|
463
|
+
records = tuple(conversation_history) if isinstance(conversation_history, (list, tuple)) else ()
|
|
464
|
+
if len(records) < 2:
|
|
465
|
+
return ()
|
|
466
|
+
user_record = _canonical_history_record(records[-2])
|
|
467
|
+
assistant_record = _canonical_history_record(records[-1])
|
|
468
|
+
if (
|
|
469
|
+
user_record is not None
|
|
470
|
+
and assistant_record is not None
|
|
471
|
+
and user_record["role"] == "user"
|
|
472
|
+
and assistant_record["role"] == "assistant"
|
|
473
|
+
):
|
|
474
|
+
return (user_record, assistant_record)
|
|
475
|
+
return ()
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
def classify_question_intent(
|
|
479
|
+
question: str,
|
|
480
|
+
conversation_history: Sequence[Mapping[str, str]] | None = None,
|
|
481
|
+
) -> str:
|
|
482
|
+
clean_question = _normalize_text(question)
|
|
483
|
+
tokens = _tokenize(clean_question)
|
|
484
|
+
if not clean_question:
|
|
485
|
+
return "tutorial"
|
|
486
|
+
if clean_question in _GREETING_TERMS:
|
|
487
|
+
return "greeting"
|
|
488
|
+
if tokens and len(tokens) <= 3 and tokens <= _GREETING_TERMS:
|
|
489
|
+
return "greeting"
|
|
490
|
+
if (
|
|
491
|
+
any(phrase in clean_question for phrase in _GREETING_PHRASES)
|
|
492
|
+
and tokens <= _GREETING_PHRASE_TERMS
|
|
493
|
+
):
|
|
494
|
+
return "greeting"
|
|
495
|
+
if is_gui_question(clean_question):
|
|
496
|
+
if _GUI_MESSAGE_RE.search(clean_question) or any(phrase in clean_question for phrase in _DIAGNOSTIC_PHRASES):
|
|
497
|
+
return "diagnostic"
|
|
498
|
+
return "tutorial"
|
|
499
|
+
explanation_follow_up = bool(re.search(
|
|
500
|
+
r"\b(?:important|matter|importa)\b", clean_question,
|
|
501
|
+
)) and not bool(re.search(
|
|
502
|
+
r"\b(?:error|warning|failed|failure|blocked|disabled|fallo|"
|
|
503
|
+
r"advertencia|bloquead\w*|deshabilitad\w*)\b", clean_question,
|
|
504
|
+
))
|
|
505
|
+
if is_follow_up_question(clean_question) and (
|
|
506
|
+
explanation_follow_up
|
|
507
|
+
or not any(phrase in clean_question for phrase in _DIAGNOSTIC_PHRASES)
|
|
508
|
+
):
|
|
509
|
+
previous_user_question = _last_user_message(conversation_history)
|
|
510
|
+
if previous_user_question and previous_user_question.strip().lower() != clean_question:
|
|
511
|
+
previous_intent = classify_question_intent(previous_user_question, conversation_history=None)
|
|
512
|
+
if previous_intent != "greeting":
|
|
513
|
+
return previous_intent
|
|
514
|
+
|
|
515
|
+
diagnostic_score = sum(3 for phrase in _DIAGNOSTIC_PHRASES if phrase in clean_question)
|
|
516
|
+
tutorial_score = sum(2 for phrase in _TUTORIAL_PHRASES if phrase in clean_question)
|
|
517
|
+
results_score = len(tokens & _RESULTS_TERMS) * 2
|
|
518
|
+
if (tokens & {"mi", "mis", "este", "esta", "estos", "estas"}
|
|
519
|
+
and tokens & {"modelo", "modelos"}
|
|
520
|
+
and re.search(r"\b(?:mejor\w*|peor\w*|confi\w*|fiab\w*|rendim\w*|compar\w*|resultados?)\b", clean_question)):
|
|
521
|
+
results_score += 4
|
|
522
|
+
parameter_score = len(tokens & _PARAMETER_TERMS) * 2
|
|
523
|
+
module_score = len(tokens & _MODULE_TERMS) * 2
|
|
524
|
+
|
|
525
|
+
if {"run", "csv"} <= tokens:
|
|
526
|
+
diagnostic_score += 2
|
|
527
|
+
if {"tab", "enabled"} <= tokens or {"tab", "disabled"} <= tokens or {"tab", "locked"} <= tokens:
|
|
528
|
+
diagnostic_score += 2
|
|
529
|
+
if "r squared" in clean_question:
|
|
530
|
+
results_score += 6
|
|
531
|
+
if "predictions" in tokens and ("identical" in tokens or "same" in tokens):
|
|
532
|
+
results_score += 6
|
|
533
|
+
diagnostic_score = max(0, diagnostic_score - 3)
|
|
534
|
+
if "pfi" in tokens and ("no_pfi" in tokens or "no pfi" in clean_question or "vs" in tokens):
|
|
535
|
+
results_score += 6
|
|
536
|
+
parameter_score = max(0, parameter_score - 2)
|
|
537
|
+
if {"parameter", "robert"} <= tokens or {"parameters", "robert"} <= tokens:
|
|
538
|
+
tutorial_score += 3
|
|
539
|
+
if {"need", "run"} <= tokens or {"need", "workflow"} <= tokens:
|
|
540
|
+
tutorial_score += 2
|
|
541
|
+
if {"what", "does"} <= tokens and tokens & _PARAMETER_TERMS:
|
|
542
|
+
parameter_score += 2
|
|
543
|
+
if {"how", "interpret"} <= tokens or {"what", "mean"} <= tokens:
|
|
544
|
+
results_score += 2
|
|
545
|
+
if "what" in tokens and tokens & _METRIC_TERMS:
|
|
546
|
+
results_score += 2
|
|
547
|
+
if tokens & _MODULE_TERMS and ("what" in tokens or "how" in tokens):
|
|
548
|
+
module_score += 1
|
|
549
|
+
|
|
550
|
+
tutorial_score += len(tokens & _TUTORIAL_TERMS)
|
|
551
|
+
|
|
552
|
+
if diagnostic_score == 0 and results_score == 0 and tutorial_score == 0 and parameter_score == 0 and module_score == 0:
|
|
553
|
+
return "tutorial"
|
|
554
|
+
if diagnostic_score >= max(tutorial_score, results_score, parameter_score, module_score):
|
|
555
|
+
return "diagnostic"
|
|
556
|
+
if parameter_score >= max(results_score, tutorial_score, module_score) and parameter_score > 0:
|
|
557
|
+
return "parameter"
|
|
558
|
+
if results_score > max(tutorial_score, module_score):
|
|
559
|
+
return "results"
|
|
560
|
+
if module_score > tutorial_score:
|
|
561
|
+
return "module-explanation"
|
|
562
|
+
return "tutorial"
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""Conservative calibration of unsupported predictive-performance guarantees."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from typing import Sequence
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
_VALIDATION = re.compile(r"\b(?:validation|validación|validacion|CV)\b", re.I)
|
|
8
|
+
_PROMISE = r"(?:guarante\w*|ensur\w*|garantiz\w*|asegur\w*)"
|
|
9
|
+
_QUALITY = r"(?:reliab\w*|accura\w*|unseen|generaliz\w*|fiabl\w*|precis\w*|no vistos)"
|
|
10
|
+
_UNSUPPORTED = re.compile(rf"\b{_PROMISE}\b[^.!?\n]{{0,140}}\b{_QUALITY}\b", re.I)
|
|
11
|
+
_NEGATED = re.compile(rf"\b(?:no|not|never|cannot|can't|doesn't)\s+(?:\w+\s+){{0,2}}{_PROMISE}", re.I)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def calibrate_validation_guarantees(text: str) -> str:
|
|
15
|
+
"""Replace a narrow class of false guarantees, retaining correct caveats."""
|
|
16
|
+
if not _VALIDATION.search(text):
|
|
17
|
+
return text
|
|
18
|
+
pieces = re.split(r"((?<=[.!?])\s+(?=[A-ZÁÉÍÓÚ])|\n+)", text)
|
|
19
|
+
corrected = False
|
|
20
|
+
spanish = False
|
|
21
|
+
for index in range(0, len(pieces), 2):
|
|
22
|
+
sentence = pieces[index]
|
|
23
|
+
if sentence.rstrip().endswith("?") or _NEGATED.search(sentence):
|
|
24
|
+
continue
|
|
25
|
+
match = _UNSUPPORTED.search(sentence)
|
|
26
|
+
if match:
|
|
27
|
+
spanish = spanish or bool(re.search(r"garantiz|asegur", match.group(), re.I))
|
|
28
|
+
pieces[index] = ""
|
|
29
|
+
corrected = True
|
|
30
|
+
if not corrected:
|
|
31
|
+
return text
|
|
32
|
+
caveat = (
|
|
33
|
+
"La validación estima el rendimiento en datos no usados para entrenar; no garantiza predicciones fiables en datos nuevos."
|
|
34
|
+
if spanish else
|
|
35
|
+
"Validation estimates performance on data held out from training; it does not guarantee reliable predictions on new data."
|
|
36
|
+
)
|
|
37
|
+
remaining = re.sub(r"\n{3,}", "\n\n", "".join(pieces)).strip()
|
|
38
|
+
return f"{remaining}\n\n{caveat}" if remaining else caveat
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def result_summary_issues(
|
|
42
|
+
text: str,
|
|
43
|
+
*,
|
|
44
|
+
metrics: Sequence[tuple[str, str, str, str]],
|
|
45
|
+
unchanged_test_set_warning: bool,
|
|
46
|
+
has_unresolved_verify_checks: bool = False,
|
|
47
|
+
) -> tuple[str, ...]:
|
|
48
|
+
"""Identify a few high-confidence contradictions before showing a report summary."""
|
|
49
|
+
issues = []
|
|
50
|
+
has_raw_test_rmse = any(
|
|
51
|
+
"rmse" in label.casefold() and "test" in scope.casefold()
|
|
52
|
+
for label, _, scope, _ in metrics
|
|
53
|
+
)
|
|
54
|
+
if has_raw_test_rmse and re.search(
|
|
55
|
+
r"\b(?:raw|unit[- ]based|original[- ]unit)\b[^.!?\n]{0,70}\bRMSE\b[^.!?\n]{0,90}"
|
|
56
|
+
r"\b(?:not (?:listed|provided|available|reported)|missing|absent|no values)\b|"
|
|
57
|
+
r"\b(?:no|without)\b[^.!?\n]{0,55}\b(?:raw|unit[- ]based)\b[^.!?\n]{0,50}\bRMSE\b",
|
|
58
|
+
text, re.I,
|
|
59
|
+
):
|
|
60
|
+
issues.append("Raw test RMSE is present in PREDICT metrics; report its value rather than saying it is absent.")
|
|
61
|
+
if re.search(
|
|
62
|
+
r"\bone[- ‑]?hot\b[^.!?\n]{0,240}\bcategorical descriptors?\b|"
|
|
63
|
+
r"\bcategorical descriptors?\b[^.!?\n]{0,240}\bone[- ‑]?hot\b|"
|
|
64
|
+
r"\bzero[- /‑]?non[- ‑]?zero\b[^.!?\n]{0,100}\bcategorical descriptors?\b",
|
|
65
|
+
text, re.I,
|
|
66
|
+
) and not re.search(r"\bnot (?:a |about )?categorical descriptor", text, re.I):
|
|
67
|
+
issues.append("VERIFY onehot tests zero/nonzero descriptor indicators; it does not identify categorical descriptors.")
|
|
68
|
+
if unchanged_test_set_warning and re.search(
|
|
69
|
+
r"\b(?:test[- ‑ ]set|test_set)\b[^.!?\n]{0,100}\b(?:forced|raised|changed|increased)\b|"
|
|
70
|
+
r"\b(?:forced|raised|changed|increased)\b[^.!?\n]{0,100}\b(?:test[- ‑ ]set|test_set)\b",
|
|
71
|
+
text, re.I,
|
|
72
|
+
):
|
|
73
|
+
issues.append("The GENERATE warning reports 0.2 before and after; do not claim the test-set size changed.")
|
|
74
|
+
if re.search(
|
|
75
|
+
r"\b(?:scores?|puntuaci[oó]n(?:es)?)\b[^.!?\n]{0,95}\b(?:moderate|modest|strong|good|poor|bad|"
|
|
76
|
+
r"moderad[ao]|buen[ao]|mal[ao])\b[^.!?\n]{0,35}\b(?:performance|rendimiento|model|modelo)\b",
|
|
77
|
+
text, re.I,
|
|
78
|
+
):
|
|
79
|
+
issues.append("A CheckML score is a checklist summary, not an absolute label for predictive quality.")
|
|
80
|
+
if re.search(
|
|
81
|
+
r"\b(?:pass(?:ed|ing)?|superad[oa]s?)\b[^.!?\n]{0,100}\b(?:not|no)\s+(?:simply\s+)?"
|
|
82
|
+
r"(?:memori[sz]\w*|overfit\w*|sobreajust\w*)\b",
|
|
83
|
+
text, re.I,
|
|
84
|
+
):
|
|
85
|
+
issues.append("Passing baseline checks does not prove the model has not memorized or overfit.")
|
|
86
|
+
if re.search(
|
|
87
|
+
r"\b(?:feature engineering|stratified sampling|re-encod\w*|reencod\w*|"
|
|
88
|
+
r"collect(?:ing)? more data|recog(?:er|ida) m[aá]s datos|muestreo estratificado)\b",
|
|
89
|
+
text, re.I,
|
|
90
|
+
):
|
|
91
|
+
issues.append("Suggest inspecting recorded report checks and CSVs, not unverified model redesign or data collection.")
|
|
92
|
+
if has_unresolved_verify_checks and re.search(
|
|
93
|
+
r"\b(?:all|every)\b[^.!?\n]{0,45}\bVERIFY\b[^.!?\n]{0,30}\bpass(?:ed|es)?\b|"
|
|
94
|
+
r"\bpass(?:ed|es)?\b[^.!?\n]{0,30}\b(?:all|every)\b[^.!?\n]{0,45}\bVERIFY\b",
|
|
95
|
+
text, re.I,
|
|
96
|
+
):
|
|
97
|
+
issues.append("At least one VERIFY check is FAILED or UNCLEAR; not all checks passed.")
|
|
98
|
+
if re.search(
|
|
99
|
+
r"\b(?:more|most|highly|very)\s+(?:reliable|robust|stable|fiable|robusto|estable)\b|"
|
|
100
|
+
r"\b(?:stronger|better)\s+(?:model\s+)?stability\b",
|
|
101
|
+
text, re.I,
|
|
102
|
+
):
|
|
103
|
+
issues.append("Reliability or model stability cannot be inferred from the score or R2 difference alone.")
|
|
104
|
+
return tuple(issues)
|