OpenFedLLMPipeline<T>

Models & Types · AiDotNet.FederatedLearning.Alignment

Implements OpenFedLLM pipeline patterns for federated LLM training, alignment, and serving.

Inheritance: FederatedLearningComponentBase<T> → OpenFedLLMPipeline<T>

For Beginners

Training a useful LLM happens in stages: first you teach it to follow instructions (instruction tuning), then you align it with human values (RLHF/DPO), and finally you deploy it (serving). OpenFedLLM defines how to do each stage in a federated setting where data stays private. This class orchestrates the three stages and manages the transitions between them.

How It Works

Pipeline stages:

Reference: Ye, J., et al. (2024). “OpenFedLLM: Training Large Language Models on Decentralized Private Data via Federated Learning.” arXiv:2402.06954.

Constructors

Constructor Summary
OpenFedLLMPipeline(OpenFedLLMOptions options) Creates a new OpenFedLLM pipeline.

Properties

Property Summary
Dictionary<string, T[]> LastCheckpoint { get; } Gets a defensive copy of the last checkpointed model parameters, or null if no checkpoint exists.
FedLLMStage CurrentStage { get; } Gets the current pipeline stage.
OpenFedLLMOptions Options { get; } Gets the pipeline configuration options.
int CurrentRound { get; } Gets the current round number within the current stage.

Methods

Method Summary
Dictionary<string, T[]> AggregateAlignment(Dictionary<int, Dictionary<string, T[]>> clientModels, Dictionary<int, double> clientWeights) Aggregates alignment-stage model parameters, using either DPO or RLHF aggregation based on the pipeline configuration.
Dictionary<string, T[]> AggregateInstructionTuning(Dictionary<int, Dictionary<string, T[]>> clientAdapters, Dictionary<int, double> clientWeights) Aggregates instruction-tuned adapter parameters from clients.
FedLLMStage AdvanceStage() Advances to the next pipeline stage, resetting the round counter.
ValueTuple<Dictionary<string, T[]>, bool> RunRound(Dictionary<int, Dictionary<string, T[]>> clientModels, Dictionary<int, double> clientWeights) Runs one round of the pipeline, dispatching to the appropriate stage-specific aggregation.
bool IsStageComplete() Checks whether the current stage has completed its allocated rounds.
void SaveCheckpoint(Dictionary<string, T[]> modelParams) Saves a checkpoint of the current model parameters.