Skip to content

Commit 4365614

Browse files
committed
fix: preserve all configuration properties across cloning and deserialization
This ensures deployment behavior, model adaptation capabilities, and training history are maintained when copying or reloading models. Updated three methods: 1. WithParameters: Now passes LoRAConfiguration, CrossValidationResult, AgentConfig, AgentRecommendation, and DeploymentConfiguration to constructor 2. DeepCopy: Same as WithParameters for consistency 3. Deserialize: Now assigns all RAG components (RagRetriever, RagReranker, RagGenerator, QueryProcessors) and configuration properties (LoRAConfiguration, CrossValidationResult, AgentConfig, AgentRecommendation, DeploymentConfiguration) from deserialized object This fixes the issue where deployment/export/runtime settings, LoRA configurations, and meta-learning properties were lost when calling WithParameters, DeepCopy, or Deserialize.
1 parent a5deb6a commit 4365614

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/Models/Results/PredictionModelResult.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,8 @@ public IFullModel<T, TInput, TOutput> WithParameters(Vector<T> parameters)
995995
updatedOptimizationResult.BestSolution = newModel;
996996

997997
// Create new result with updated optimization result
998-
// Use constructor that preserves BiasDetector, FairnessEvaluator, and RAG components
998+
// Preserve all configuration properties to ensure deployment behavior, model adaptation,
999+
// and training history are maintained across parameter updates
9991000
return new PredictionModelResult<T, TInput, TOutput>(
10001001
updatedOptimizationResult,
10011002
NormalizationInfo,
@@ -1004,7 +1005,12 @@ public IFullModel<T, TInput, TOutput> WithParameters(Vector<T> parameters)
10041005
RagRetriever,
10051006
RagReranker,
10061007
RagGenerator,
1007-
QueryProcessors);
1008+
QueryProcessors,
1009+
loraConfiguration: LoRAConfiguration,
1010+
crossValidationResult: CrossValidationResult,
1011+
agentConfig: AgentConfig,
1012+
agentRecommendation: AgentRecommendation,
1013+
deploymentConfiguration: DeploymentConfiguration);
10081014
}
10091015

10101016
/// <summary>
@@ -1090,7 +1096,8 @@ public IFullModel<T, TInput, TOutput> DeepCopy()
10901096

10911097
var clonedNormalizationInfo = NormalizationInfo.DeepCopy();
10921098

1093-
// Use constructor that preserves BiasDetector, FairnessEvaluator, and RAG components
1099+
// Preserve all configuration properties to ensure deployment behavior, model adaptation,
1100+
// and training history are maintained across deep copy
10941101
return new PredictionModelResult<T, TInput, TOutput>(
10951102
clonedOptimizationResult,
10961103
clonedNormalizationInfo,
@@ -1099,7 +1106,12 @@ public IFullModel<T, TInput, TOutput> DeepCopy()
10991106
RagRetriever,
11001107
RagReranker,
11011108
RagGenerator,
1102-
QueryProcessors);
1109+
QueryProcessors,
1110+
loraConfiguration: LoRAConfiguration,
1111+
crossValidationResult: CrossValidationResult,
1112+
agentConfig: AgentConfig,
1113+
agentRecommendation: AgentRecommendation,
1114+
deploymentConfiguration: DeploymentConfiguration);
11031115
}
11041116

11051117
/// <summary>
@@ -1218,6 +1230,17 @@ public void Deserialize(byte[] data)
12181230
ModelMetaData = deserializedObject.ModelMetaData;
12191231
BiasDetector = deserializedObject.BiasDetector;
12201232
FairnessEvaluator = deserializedObject.FairnessEvaluator;
1233+
1234+
// Preserve RAG components and all configuration properties
1235+
RagRetriever = deserializedObject.RagRetriever;
1236+
RagReranker = deserializedObject.RagReranker;
1237+
RagGenerator = deserializedObject.RagGenerator;
1238+
QueryProcessors = deserializedObject.QueryProcessors;
1239+
LoRAConfiguration = deserializedObject.LoRAConfiguration;
1240+
CrossValidationResult = deserializedObject.CrossValidationResult;
1241+
AgentConfig = deserializedObject.AgentConfig;
1242+
AgentRecommendation = deserializedObject.AgentRecommendation;
1243+
DeploymentConfiguration = deserializedObject.DeploymentConfiguration;
12211244
}
12221245
else
12231246
{

0 commit comments

Comments
 (0)