nvidia-nat 1.4.0a20251022__py3-none-any.whl → 1.4.0a20251023__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.
- nat/data_models/api_server.py +2 -0
- nat/eval/rag_evaluator/evaluate.py +7 -4
- nat/profiler/parameter_optimization/parameter_optimizer.py +11 -0
- nat/profiler/parameter_optimization/pareto_visualizer.py +31 -16
- {nvidia_nat-1.4.0a20251022.dist-info → nvidia_nat-1.4.0a20251023.dist-info}/METADATA +1 -1
- {nvidia_nat-1.4.0a20251022.dist-info → nvidia_nat-1.4.0a20251023.dist-info}/RECORD +11 -11
- {nvidia_nat-1.4.0a20251022.dist-info → nvidia_nat-1.4.0a20251023.dist-info}/WHEEL +0 -0
- {nvidia_nat-1.4.0a20251022.dist-info → nvidia_nat-1.4.0a20251023.dist-info}/entry_points.txt +0 -0
- {nvidia_nat-1.4.0a20251022.dist-info → nvidia_nat-1.4.0a20251023.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat-1.4.0a20251022.dist-info → nvidia_nat-1.4.0a20251023.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat-1.4.0a20251022.dist-info → nvidia_nat-1.4.0a20251023.dist-info}/top_level.txt +0 -0
nat/data_models/api_server.py
CHANGED
|
@@ -608,6 +608,8 @@ class WebSocketUserInteractionResponseMessage(BaseModel):
|
|
|
608
608
|
type: typing.Literal[WebSocketMessageType.USER_INTERACTION_MESSAGE]
|
|
609
609
|
id: str = "default"
|
|
610
610
|
thread_id: str = "default"
|
|
611
|
+
parent_id: str = "default"
|
|
612
|
+
conversation_id: str | None = None
|
|
611
613
|
content: UserMessageContent
|
|
612
614
|
user: User = User()
|
|
613
615
|
security: Security = Security()
|
|
@@ -116,11 +116,14 @@ class RAGEvaluator:
|
|
|
116
116
|
"""Convert NaN or None to 0.0 for safe arithmetic/serialization."""
|
|
117
117
|
return 0.0 if v is None or (isinstance(v, float) and math.isnan(v)) else v
|
|
118
118
|
|
|
119
|
-
#
|
|
119
|
+
# Keep original scores (preserving NaN/None) for output
|
|
120
|
+
original_scores_dict = {metric: [score.get(metric) for score in scores] for metric in scores[0]}
|
|
121
|
+
|
|
122
|
+
# Convert from list of dicts to dict of lists, coercing NaN/None to 0.0 for average calculation
|
|
120
123
|
scores_dict = {metric: [_nan_to_zero(score.get(metric)) for score in scores] for metric in scores[0]}
|
|
121
124
|
first_metric_name = list(scores_dict.keys())[0] if scores_dict else None
|
|
122
125
|
|
|
123
|
-
# Compute the average of each metric
|
|
126
|
+
# Compute the average of each metric using cleaned scores (NaN/None -> 0.0)
|
|
124
127
|
average_scores = {
|
|
125
128
|
metric: (sum(values) / len(values) if values else 0.0)
|
|
126
129
|
for metric, values in scores_dict.items()
|
|
@@ -137,11 +140,11 @@ class RAGEvaluator:
|
|
|
137
140
|
else:
|
|
138
141
|
ids = df["user_input"].tolist() # Use "user_input" as ID fallback
|
|
139
142
|
|
|
140
|
-
# Construct EvalOutputItem list
|
|
143
|
+
# Construct EvalOutputItem list using original scores (preserving NaN/None)
|
|
141
144
|
eval_output_items = [
|
|
142
145
|
EvalOutputItem(
|
|
143
146
|
id=ids[i],
|
|
144
|
-
score=
|
|
147
|
+
score=original_scores_dict[first_metric_name][i] if first_metric_name else None,
|
|
145
148
|
reasoning={
|
|
146
149
|
key:
|
|
147
150
|
getattr(row, key, None) # Use getattr to safely access attributes
|
|
@@ -121,6 +121,17 @@ def optimize_parameters(
|
|
|
121
121
|
with (out_dir / "trials_dataframe_params.csv").open("w") as fh:
|
|
122
122
|
# Export full trials DataFrame (values, params, timings, etc.).
|
|
123
123
|
df = study.trials_dataframe()
|
|
124
|
+
|
|
125
|
+
# Rename values_X columns to actual metric names
|
|
126
|
+
metric_names = list(metric_cfg.keys())
|
|
127
|
+
rename_mapping = {}
|
|
128
|
+
for i, metric_name in enumerate(metric_names):
|
|
129
|
+
old_col = f"values_{i}"
|
|
130
|
+
if old_col in df.columns:
|
|
131
|
+
rename_mapping[old_col] = f"values_{metric_name}"
|
|
132
|
+
if rename_mapping:
|
|
133
|
+
df = df.rename(columns=rename_mapping)
|
|
134
|
+
|
|
124
135
|
# Normalise rep_scores column naming for convenience.
|
|
125
136
|
if "user_attrs_rep_scores" in df.columns and "rep_scores" not in df.columns:
|
|
126
137
|
df = df.rename(columns={"user_attrs_rep_scores": "rep_scores"})
|
|
@@ -46,9 +46,13 @@ class ParetoVisualizer:
|
|
|
46
46
|
|
|
47
47
|
fig, ax = plt.subplots(figsize=figsize)
|
|
48
48
|
|
|
49
|
-
# Extract metric values
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
# Extract metric values - support both old (values_0) and new (values_metricname) formats
|
|
50
|
+
x_col = f"values_{self.metric_names[0]}" \
|
|
51
|
+
if f"values_{self.metric_names[0]}" in trials_df.columns else f"values_{0}"
|
|
52
|
+
y_col = f"values_{self.metric_names[1]}"\
|
|
53
|
+
if f"values_{self.metric_names[1]}" in trials_df.columns else f"values_{1}"
|
|
54
|
+
x_vals = trials_df[x_col].values
|
|
55
|
+
y_vals = trials_df[y_col].values
|
|
52
56
|
|
|
53
57
|
# Plot all trials
|
|
54
58
|
ax.scatter(x_vals,
|
|
@@ -62,8 +66,8 @@ class ParetoVisualizer:
|
|
|
62
66
|
|
|
63
67
|
# Plot Pareto optimal trials if provided
|
|
64
68
|
if pareto_trials_df is not None and not pareto_trials_df.empty:
|
|
65
|
-
pareto_x = pareto_trials_df[
|
|
66
|
-
pareto_y = pareto_trials_df[
|
|
69
|
+
pareto_x = pareto_trials_df[x_col].values
|
|
70
|
+
pareto_y = pareto_trials_df[y_col].values
|
|
67
71
|
|
|
68
72
|
ax.scatter(pareto_x,
|
|
69
73
|
pareto_y,
|
|
@@ -98,8 +102,8 @@ class ParetoVisualizer:
|
|
|
98
102
|
ax.grid(True, alpha=0.3)
|
|
99
103
|
|
|
100
104
|
# Add direction annotations
|
|
101
|
-
x_annotation = (f"Better {self.metric_names[0]}
|
|
102
|
-
if self.directions[0] == "minimize" else f"
|
|
105
|
+
x_annotation = (f"Better {self.metric_names[0]} ←"
|
|
106
|
+
if self.directions[0] == "minimize" else f"→ Better {self.metric_names[0]}")
|
|
103
107
|
ax.annotate(x_annotation,
|
|
104
108
|
xy=(0.02, 0.98),
|
|
105
109
|
xycoords='axes fraction',
|
|
@@ -109,8 +113,8 @@ class ParetoVisualizer:
|
|
|
109
113
|
style='italic',
|
|
110
114
|
bbox=dict(boxstyle="round,pad=0.3", facecolor="wheat", alpha=0.7))
|
|
111
115
|
|
|
112
|
-
y_annotation = (f"Better {self.metric_names[1]}
|
|
113
|
-
if self.directions[1] == "minimize" else f"Better {self.metric_names[1]}
|
|
116
|
+
y_annotation = (f"Better {self.metric_names[1]} ↓"
|
|
117
|
+
if self.directions[1] == "minimize" else f"Better {self.metric_names[1]} ↑")
|
|
114
118
|
ax.annotate(y_annotation,
|
|
115
119
|
xy=(0.02, 0.02),
|
|
116
120
|
xycoords='axes fraction',
|
|
@@ -145,7 +149,10 @@ class ParetoVisualizer:
|
|
|
145
149
|
# Normalize values for better visualization
|
|
146
150
|
all_values = []
|
|
147
151
|
for i in range(n_metrics):
|
|
148
|
-
|
|
152
|
+
# Support both old (values_0) and new (values_metricname) formats
|
|
153
|
+
col_name = f"values_{self.metric_names[i]}"\
|
|
154
|
+
if f"values_{self.metric_names[i]}" in trials_df.columns else f"values_{i}"
|
|
155
|
+
all_values.append(trials_df[col_name].values)
|
|
149
156
|
|
|
150
157
|
# Normalize each metric to [0, 1] for parallel coordinates
|
|
151
158
|
normalized_values = []
|
|
@@ -221,23 +228,31 @@ class ParetoVisualizer:
|
|
|
221
228
|
|
|
222
229
|
if i == j:
|
|
223
230
|
# Diagonal: histograms
|
|
224
|
-
|
|
231
|
+
# Support both old (values_0) and new (values_metricname) formats
|
|
232
|
+
col_name = f"values_{self.metric_names[i]}"\
|
|
233
|
+
if f"values_{self.metric_names[i]}" in trials_df.columns else f"values_{i}"
|
|
234
|
+
values = trials_df[col_name].values
|
|
225
235
|
ax.hist(values, bins=20, alpha=0.7, color='lightblue', edgecolor='navy')
|
|
226
236
|
if pareto_trials_df is not None and not pareto_trials_df.empty:
|
|
227
|
-
pareto_values = pareto_trials_df[
|
|
237
|
+
pareto_values = pareto_trials_df[col_name].values
|
|
228
238
|
ax.hist(pareto_values, bins=20, alpha=0.8, color='red', edgecolor='darkred')
|
|
229
239
|
ax.set_xlabel(f"{self.metric_names[i]}")
|
|
230
240
|
ax.set_ylabel("Frequency")
|
|
231
241
|
else:
|
|
232
242
|
# Off-diagonal: scatter plots
|
|
233
|
-
|
|
234
|
-
|
|
243
|
+
# Support both old (values_0) and new (values_metricname) formats
|
|
244
|
+
x_col = f"values_{self.metric_names[j]}"\
|
|
245
|
+
if f"values_{self.metric_names[j]}" in trials_df.columns else f"values_{j}"
|
|
246
|
+
y_col = f"values_{self.metric_names[i]}"\
|
|
247
|
+
if f"values_{self.metric_names[i]}" in trials_df.columns else f"values_{i}"
|
|
248
|
+
x_vals = trials_df[x_col].values
|
|
249
|
+
y_vals = trials_df[y_col].values
|
|
235
250
|
|
|
236
251
|
ax.scatter(x_vals, y_vals, alpha=0.6, s=30, c='lightblue', edgecolors='navy', linewidths=0.5)
|
|
237
252
|
|
|
238
253
|
if pareto_trials_df is not None and not pareto_trials_df.empty:
|
|
239
|
-
pareto_x = pareto_trials_df[
|
|
240
|
-
pareto_y = pareto_trials_df[
|
|
254
|
+
pareto_x = pareto_trials_df[x_col].values
|
|
255
|
+
pareto_y = pareto_trials_df[y_col].values
|
|
241
256
|
ax.scatter(pareto_x,
|
|
242
257
|
pareto_y,
|
|
243
258
|
alpha=0.9,
|
|
@@ -114,7 +114,7 @@ nat/control_flow/router_agent/prompt.py,sha256=fIAiNsAs1zXRAatButR76zSpHJNxSkXXK
|
|
|
114
114
|
nat/control_flow/router_agent/register.py,sha256=4RGmS9sy-QtIMmvh8mfMcR1VqxFPLpG4RckWCIExh40,4144
|
|
115
115
|
nat/data_models/__init__.py,sha256=Xs1JQ16L9btwreh4pdGKwskffAw1YFO48jKrU4ib_7c,685
|
|
116
116
|
nat/data_models/agent.py,sha256=IwDyb9Zc3R4Zd5rFeqt7q0EQswczAl5focxV9KozIzs,1625
|
|
117
|
-
nat/data_models/api_server.py,sha256=
|
|
117
|
+
nat/data_models/api_server.py,sha256=oQtSiP7jpkHIZ75g21A_lTiidNsQo54pq3qy2StIJcs,30652
|
|
118
118
|
nat/data_models/authentication.py,sha256=XPu9W8nh4XRSuxPv3HxO-FMQ_JtTEoK6Y02JwnzDwTg,8457
|
|
119
119
|
nat/data_models/common.py,sha256=nXXfGrjpxebzBUa55mLdmzePLt7VFHvTAc6Znj3yEv0,5875
|
|
120
120
|
nat/data_models/component.py,sha256=b_hXOA8Gm5UNvlFkAhsR6kEvf33ST50MKtr5kWf75Ao,1894
|
|
@@ -173,7 +173,7 @@ nat/eval/evaluator/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQ
|
|
|
173
173
|
nat/eval/evaluator/base_evaluator.py,sha256=5WaVGhCGzkynCJyQdxRv7CtqLoUpr6B4O8tilP_gb3g,3232
|
|
174
174
|
nat/eval/evaluator/evaluator_model.py,sha256=riGCcDW8YwC3Kd1yoVmbMdJE1Yf2kVmO8uhsGsKKJA4,1878
|
|
175
175
|
nat/eval/rag_evaluator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
176
|
-
nat/eval/rag_evaluator/evaluate.py,sha256=
|
|
176
|
+
nat/eval/rag_evaluator/evaluate.py,sha256=IfCpfCKBTYhReRkPPbOqyr-9H6gsPGaeFWBIcGDUynw,8639
|
|
177
177
|
nat/eval/rag_evaluator/register.py,sha256=AzT5uICDU5dEo7scvStmOWC7ac-S0Tx4UY87idGtXIs,5835
|
|
178
178
|
nat/eval/runners/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQg,680
|
|
179
179
|
nat/eval/runners/config.py,sha256=bRPai_th02OJrFepbbY6w-t7A18TBXozQUnnnH9iWIU,1403
|
|
@@ -371,9 +371,9 @@ nat/profiler/inference_optimization/experimental/prefix_span_analysis.py,sha256=
|
|
|
371
371
|
nat/profiler/parameter_optimization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
372
372
|
nat/profiler/parameter_optimization/optimizable_utils.py,sha256=93Pl8A14Zq_f3XsxSH-yFnEJ6B7W5hp7doPnPoLlRB4,3714
|
|
373
373
|
nat/profiler/parameter_optimization/optimizer_runtime.py,sha256=rXmCOq81o7ZorQOUYociVjuO3NO9CIjFBbwql2u_4H4,2715
|
|
374
|
-
nat/profiler/parameter_optimization/parameter_optimizer.py,sha256=
|
|
374
|
+
nat/profiler/parameter_optimization/parameter_optimizer.py,sha256=LA2gTBTuezWg5tdqyPA2VjIPkXylgwU9EHpVyaQqBxM,6951
|
|
375
375
|
nat/profiler/parameter_optimization/parameter_selection.py,sha256=pfnNQIx1evNICgChsOJXIFQHoL1R_kmh_vNDsVMC9kg,3982
|
|
376
|
-
nat/profiler/parameter_optimization/pareto_visualizer.py,sha256=
|
|
376
|
+
nat/profiler/parameter_optimization/pareto_visualizer.py,sha256=QclLZmmsWINIAh4n0XAKmnIZOqGHTMr-iggZS0kxj-Y,17055
|
|
377
377
|
nat/profiler/parameter_optimization/prompt_optimizer.py,sha256=_AmdeB1jRamd93qR5UqRy5LweYR3bjnD7zoLxzXYE0k,17658
|
|
378
378
|
nat/profiler/parameter_optimization/update_helpers.py,sha256=NxWhrGVchbjws85pPd-jS-C14_l70QvVSvEfENndVcY,2339
|
|
379
379
|
nat/registry_handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -475,10 +475,10 @@ nat/utils/reactive/base/observer_base.py,sha256=6BiQfx26EMumotJ3KoVcdmFBYR_fnAss
|
|
|
475
475
|
nat/utils/reactive/base/subject_base.py,sha256=UQOxlkZTIeeyYmG5qLtDpNf_63Y7p-doEeUA08_R8ME,2521
|
|
476
476
|
nat/utils/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
477
477
|
nat/utils/settings/global_settings.py,sha256=9JaO6pxKT_Pjw6rxJRsRlFCXdVKCl_xUKU2QHZQWWNM,7294
|
|
478
|
-
nvidia_nat-1.4.
|
|
479
|
-
nvidia_nat-1.4.
|
|
480
|
-
nvidia_nat-1.4.
|
|
481
|
-
nvidia_nat-1.4.
|
|
482
|
-
nvidia_nat-1.4.
|
|
483
|
-
nvidia_nat-1.4.
|
|
484
|
-
nvidia_nat-1.4.
|
|
478
|
+
nvidia_nat-1.4.0a20251023.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
|
479
|
+
nvidia_nat-1.4.0a20251023.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
480
|
+
nvidia_nat-1.4.0a20251023.dist-info/METADATA,sha256=MMZ-DFHfnYlCQnt2lGODZr64QXxzis2i-Dz6skRoTtM,10248
|
|
481
|
+
nvidia_nat-1.4.0a20251023.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
482
|
+
nvidia_nat-1.4.0a20251023.dist-info/entry_points.txt,sha256=4jCqjyETMpyoWbCBf4GalZU8I_wbstpzwQNezdAVbbo,698
|
|
483
|
+
nvidia_nat-1.4.0a20251023.dist-info/top_level.txt,sha256=lgJWLkigiVZuZ_O1nxVnD_ziYBwgpE2OStdaCduMEGc,8
|
|
484
|
+
nvidia_nat-1.4.0a20251023.dist-info/RECORD,,
|
|
File without changes
|
{nvidia_nat-1.4.0a20251022.dist-info → nvidia_nat-1.4.0a20251023.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{nvidia_nat-1.4.0a20251022.dist-info → nvidia_nat-1.4.0a20251023.dist-info}/licenses/LICENSE.md
RENAMED
|
File without changes
|
|
File without changes
|