Diadochi - The Multi-Domain LLM Orchestration Framework
Named After
Diadochi is named after the succession of Alexander the Great’s generals who divided his empire into specialized kingdoms after his death in 323 BCE. Each Diadochi (“successors” in Greek) became an expert ruler of their specific domain—Ptolemy in Egypt, Seleucus in Babylon, Antigonus in Asia Minor—while maintaining communication and occasionally collaborating or competing with each other.
Just as the historical Diadochi were specialist rulers who could be called upon for domain-specific expertise, the Diadochi framework orchestrates specialized language models, each expert in their particular domain, coordinating their knowledge to provide comprehensive analysis that no single model could achieve alone.
Core Philosophy
Diadochi addresses the fundamental limitation that “no single model can be expert in everything” and “true intelligence emerges from expert collaboration”. While general-purpose language models are remarkably capable, they cannot match the depth of models specifically trained and fine-tuned for particular domains.
The framework operates on four core principles:
- Domain Specialization: Different domains require different types of expertise and reasoning patterns
- Intelligent Routing: The choice of which experts to consult should be based on deep understanding of the problem
- Collaborative Synthesis: Multiple expert opinions must be synthesized using principled methods
- Cost-Benefit Optimization: External API calls have costs that must be balanced against expected benefits
The Expertise Problem in AI Systems
Traditional approaches to domain expertise suffer from several limitations:
- Jack-of-All-Trades Problem: General models lack deep domain-specific knowledge
- Training Data Limitations: No single model can be optimally trained on all domains simultaneously
- Specialization Benefits: Domain-specific models outperform general models in their areas of expertise
- Knowledge Currency: Different domains evolve at different rates, requiring specialized updates
- Reasoning Patterns: Different fields use fundamentally different approaches to problem-solving
Diadochi transforms this challenge into a strategic advantage by coordinating specialist expertise.
Technical Architecture
Domain Intelligence Router
The core of Diadochi is its intelligent routing system that analyzes content and determines which specialist models to consult:
pub struct DomainIntelligenceRouter {
domain_classifiers: HashMap<Domain, DomainClassifier>,
complexity_analyzers: HashMap<Domain, ComplexityAnalyzer>,
expertise_requirements_assessor: ExpertiseRequirementsAssessor,
model_registry: SpecialistModelRegistry,
routing_strategies: HashMap<RoutingStrategy, RoutingEngine>,
}
pub struct ExpertiseRequirement {
domain: Domain,
complexity_level: ComplexityLevel,
reasoning_type: ReasoningType,
confidence_requirement: f64,
cost_tolerance: f64,
urgency: UrgencyLevel,
}
pub enum Domain {
Medical {
subspecialty: MedicalSpecialty,
evidence_level_required: EvidenceLevel,
},
Legal {
jurisdiction: Jurisdiction,
area_of_law: LegalArea,
},
Scientific {
field: ScientificField,
methodology: ResearchMethodology,
},
Technical {
domain: TechnicalDomain,
complexity: TechnicalComplexity,
},
Financial {
market: FinancialMarket,
analysis_type: FinancialAnalysisType,
},
Academic {
discipline: AcademicDiscipline,
level: AcademicLevel,
},
}
impl DomainIntelligenceRouter {
pub fn analyze_expertise_requirements(&self, text: &str, context: &ProcessingContext) -> Vec<ExpertiseRequirement> {
let mut requirements = Vec::new();
// Analyze text for domain indicators
let domain_signals = self.extract_domain_signals(text);
for signal in domain_signals {
let domain = self.classify_domain(&signal);
let complexity = self.assess_complexity(&signal, &domain);
let reasoning_type = self.determine_reasoning_requirements(&signal, &domain);
requirements.push(ExpertiseRequirement {
domain,
complexity_level: complexity,
reasoning_type,
confidence_requirement: self.determine_confidence_requirement(context),
cost_tolerance: context.cost_tolerance,
urgency: context.urgency,
});
}
// Remove redundant requirements and optimize the set
self.optimize_requirements_set(requirements)
}
pub fn route_to_specialists(&self, requirements: &[ExpertiseRequirement]) -> RoutingPlan {
let mut routing_plan = RoutingPlan::new();
for requirement in requirements {
// Find the best specialist model for this requirement
let candidate_models = self.model_registry.find_specialists(&requirement.domain);
let optimal_model = self.select_optimal_model(candidate_models, requirement);
// Determine the specific query to send to this specialist
let specialist_query = self.formulate_specialist_query(requirement, &optimal_model);
routing_plan.add_consultation(SpecialistConsultation {
model: optimal_model,
query: specialist_query,
expected_cost: self.estimate_consultation_cost(&optimal_model, &specialist_query),
expected_value: self.estimate_consultation_value(requirement, &optimal_model),
priority: self.calculate_priority(requirement),
});
}
// Optimize the overall routing plan
self.optimize_routing_plan(routing_plan)
}
}
Specialist Model Registry
Diadochi maintains a comprehensive registry of available specialist models:
pub struct SpecialistModelRegistry {
huggingface_models: HashMap<Domain, Vec<HuggingFaceModel>>,
openai_models: HashMap<Domain, Vec<OpenAIModel>>,
anthropic_models: HashMap<Domain, Vec<AnthropicModel>>,
custom_models: HashMap<Domain, Vec<CustomModel>>,
model_performance_metrics: HashMap<ModelId, PerformanceMetrics>,
model_cost_data: HashMap<ModelId, CostData>,
}
pub struct SpecialistModel {
id: ModelId,
name: String,
provider: ModelProvider,
domain_expertise: Vec<Domain>,
performance_metrics: PerformanceMetrics,
cost_structure: CostStructure,
api_endpoint: APIEndpoint,
context_window: usize,
reasoning_capabilities: ReasoningCapabilities,
knowledge_cutoff: Option<DateTime<Utc>>,
specialization_depth: SpecializationDepth,
}
pub struct PerformanceMetrics {
domain_accuracy: HashMap<Domain, f64>,
reasoning_quality: f64,
consistency_score: f64,
response_time: Duration,
reliability_score: f64,
factual_accuracy: f64,
bias_score: f64,
calibration_score: f64, // How well confidence matches actual accuracy
}
impl SpecialistModelRegistry {
pub fn find_optimal_specialist(&self, requirement: &ExpertiseRequirement) -> Option<SpecialistModel> {
let candidates = self.find_candidates_for_domain(&requirement.domain);
let scored_candidates: Vec<_> = candidates
.into_iter()
.map(|model| {
let score = self.calculate_suitability_score(&model, requirement);
(model, score)
})
.collect();
// Sort by suitability score and return the best match
scored_candidates
.into_iter()
.max_by(|a, b| a.1.partial_cmp(&b.1).unwrap_or(std::cmp::Ordering::Equal))
.map(|(model, _)| model)
}
fn calculate_suitability_score(&self, model: &SpecialistModel, requirement: &ExpertiseRequirement) -> f64 {
let domain_expertise_score = self.assess_domain_expertise(model, &requirement.domain);
let complexity_handling_score = self.assess_complexity_handling(model, requirement.complexity_level);
let reasoning_capability_score = self.assess_reasoning_capability(model, requirement.reasoning_type);
let cost_efficiency_score = self.assess_cost_efficiency(model, requirement.cost_tolerance);
let reliability_score = model.performance_metrics.reliability_score;
// Weighted combination of factors
domain_expertise_score * 0.3
+ complexity_handling_score * 0.2
+ reasoning_capability_score * 0.2
+ cost_efficiency_score * 0.15
+ reliability_score * 0.15
}
}
HuggingFace API Integration
Seamless integration with the HuggingFace model ecosystem:
pub struct HuggingFaceIntegration {
api_client: HuggingFaceAPIClient,
model_cache: ModelCache,
rate_limiter: RateLimiter,
cost_tracker: CostTracker,
}
pub struct HuggingFaceAPIClient {
api_token: String,
base_url: String,
timeout: Duration,
retry_policy: RetryPolicy,
}
impl HuggingFaceIntegration {
pub async fn consult_specialist(
&self,
model_id: &str,
query: &SpecialistQuery,
context: &ConsultationContext,
) -> Result<SpecialistResponse, ConsultationError> {
// Check rate limits
self.rate_limiter.check_and_reserve(model_id).await?;
// Prepare the API request
let request = self.prepare_huggingface_request(model_id, query, context)?;
// Track costs
let estimated_cost = self.cost_tracker.estimate_request_cost(&request);
self.cost_tracker.reserve_budget(estimated_cost)?;
// Make the API call
let raw_response = self.api_client.send_request(request).await?;
// Process and validate the response
let processed_response = self.process_specialist_response(raw_response, query)?;
// Update cost tracking with actual costs
let actual_cost = self.extract_actual_cost(&processed_response);
self.cost_tracker.record_actual_cost(actual_cost);
// Cache the response for potential reuse
self.model_cache.store_response(model_id, query, &processed_response);
Ok(processed_response)
}
fn prepare_huggingface_request(
&self,
model_id: &str,
query: &SpecialistQuery,
context: &ConsultationContext,
) -> Result<HuggingFaceRequest, PreprationError> {
let model_info = self.get_model_info(model_id)?;
// Adapt the query format for the specific model
let formatted_prompt = self.format_prompt_for_model(query, &model_info);
// Set appropriate parameters based on model capabilities
let parameters = HuggingFaceParameters {
max_new_tokens: self.calculate_max_tokens(query, &model_info),
temperature: self.determine_temperature(context.reasoning_type),
top_p: self.determine_top_p(context.confidence_requirement),
do_sample: context.reasoning_type.requires_sampling(),
return_full_text: false,
clean_up_tokenization_spaces: true,
};
Ok(HuggingFaceRequest {
model: model_id.to_string(),
inputs: formatted_prompt,
parameters,
options: self.build_request_options(context),
})
}
}
Expert Collaboration Protocol
Sophisticated system for combining insights from multiple specialist models:
pub struct ExpertCollaborationProtocol {
consensus_builder: ConsensusBuilder,
evidence_synthesizer: EvidenceSynthesizer,
conflict_resolver: ConflictResolver,
confidence_aggregator: ConfidenceAggregator,
}
pub struct CollaborationSession {
session_id: SessionId,
participating_experts: Vec<SpecialistModel>,
consultation_results: Vec<SpecialistResponse>,
synthesis_strategy: SynthesisStrategy,
confidence_requirements: ConfidenceRequirements,
}
pub enum SynthesisStrategy {
WeightedConsensus {
weights: HashMap<ModelId, f64>,
agreement_threshold: f64,
},
EvidenceBasedSynthesis {
evidence_quality_weights: EvidenceQualityWeights,
source_credibility_weights: SourceCredibilityWeights,
},
BayesianAggregation {
prior_beliefs: PriorBeliefs,
likelihood_functions: LikelihoodFunctions,
},
ExpertDebate {
debate_rounds: usize,
convergence_threshold: f64,
},
}
impl ExpertCollaborationProtocol {
pub async fn orchestrate_collaboration(
&self,
query: &ComplexQuery,
selected_experts: &[SpecialistModel],
) -> CollaborationResult {
let session = self.initialize_collaboration_session(query, selected_experts);
// Phase 1: Independent consultation
let independent_responses = self.gather_independent_responses(&session).await;
// Phase 2: Identify conflicts and agreements
let analysis = self.analyze_response_patterns(&independent_responses);
// Phase 3: Synthesize responses based on strategy
let synthesis = match &session.synthesis_strategy {
SynthesisStrategy::WeightedConsensus { weights, agreement_threshold } => {
self.consensus_builder.build_weighted_consensus(
&independent_responses,
weights,
*agreement_threshold,
)
}
SynthesisStrategy::EvidenceBasedSynthesis { evidence_quality_weights, source_credibility_weights } => {
self.evidence_synthesizer.synthesize_evidence_based(
&independent_responses,
evidence_quality_weights,
source_credibility_weights,
)
}
SynthesisStrategy::BayesianAggregation { prior_beliefs, likelihood_functions } => {
self.perform_bayesian_aggregation(
&independent_responses,
prior_beliefs,
likelihood_functions,
)
}
SynthesisStrategy::ExpertDebate { debate_rounds, convergence_threshold } => {
self.facilitate_expert_debate(
&session,
*debate_rounds,
*convergence_threshold,
).await
}
};
// Phase 4: Validate and finalize
let validated_synthesis = self.validate_synthesis(&synthesis, &session);
CollaborationResult {
synthesized_response: validated_synthesis,
individual_expert_responses: independent_responses,
collaboration_metadata: self.generate_collaboration_metadata(&session),
confidence_metrics: self.calculate_collaboration_confidence(&synthesis),
cost_breakdown: self.calculate_collaboration_costs(&session),
}
}
async fn facilitate_expert_debate(
&self,
session: &CollaborationSession,
rounds: usize,
convergence_threshold: f64,
) -> SynthesisResult {
let mut current_positions = self.extract_initial_positions(&session.consultation_results);
let mut round = 0;
while round < rounds {
// Identify areas of disagreement
let disagreements = self.identify_disagreements(¤t_positions);
if disagreements.is_empty() || self.calculate_convergence(¤t_positions) > convergence_threshold {
break;
}
// Generate follow-up questions for each expert based on disagreements
let follow_up_queries = self.generate_follow_up_queries(&disagreements, ¤t_positions);
// Get expert responses to follow-up questions
let follow_up_responses = self.gather_follow_up_responses(&follow_up_queries).await;
// Update positions based on new information
current_positions = self.update_positions(¤t_positions, &follow_up_responses);
round += 1;
}
// Synthesize final consensus
self.synthesize_final_consensus(¤t_positions)
}
}
Integration with Core Intelligence Modules
Diadochi leverages the existing five intelligence modules for enhanced decision-making:
Hatata Integration - Cost-Benefit Optimization
impl DiadochiHatataIntegration {
pub fn optimize_consultation_strategy(&self, requirements: &[ExpertiseRequirement]) -> ConsultationStrategy {
let consultation_states = self.enumerate_consultation_states(requirements);
let utilities = consultation_states.iter().map(|state| {
self.calculate_consultation_utility(state, requirements)
}).collect::<Vec<_>>();
let optimal_state_index = utilities
.iter()
.enumerate()
.max_by(|a, b| a.1.partial_cmp(b.1).unwrap_or(std::cmp::Ordering::Equal))
.map(|(index, _)| index)
.unwrap();
ConsultationStrategy {
selected_experts: consultation_states[optimal_state_index].clone(),
expected_utility: utilities[optimal_state_index],
cost_analysis: self.analyze_consultation_costs(&consultation_states[optimal_state_index]),
risk_assessment: self.assess_consultation_risks(&consultation_states[optimal_state_index]),
}
}
fn calculate_consultation_utility(&self, state: &ConsultationState, requirements: &[ExpertiseRequirement]) -> f64 {
let expertise_coverage_benefit = self.calculate_expertise_coverage(state, requirements);
let quality_improvement_benefit = self.estimate_quality_improvement(state);
let cost = self.estimate_total_cost(state);
let time_cost = self.estimate_time_cost(state);
let risk_penalty = self.estimate_risk_penalty(state);
// Utility function balancing benefits against costs
expertise_coverage_benefit * 0.3
+ quality_improvement_benefit * 0.3
- cost * 0.25
- time_cost * 0.1
- risk_penalty * 0.05
}
}
Diggiden Integration - Quality Validation
impl DiadochiDiggidenIntegration {
pub fn validate_specialist_responses(&self, responses: &[SpecialistResponse]) -> ValidationResults {
let mut validation_results = Vec::new();
for response in responses {
// Test for common failure modes
let validation_result = ValidationResult {
factual_accuracy_score: self.test_factual_accuracy(response),
consistency_score: self.test_internal_consistency(response),
bias_detection_score: self.test_for_bias(response),
hallucination_detection_score: self.test_for_hallucination(response),
confidence_calibration_score: self.test_confidence_calibration(response),
adversarial_robustness_score: self.test_adversarial_robustness(response),
};
validation_results.push((response.model_id.clone(), validation_result));
}
ValidationResults {
individual_validations: validation_results,
overall_reliability_score: self.calculate_overall_reliability(&validation_results),
identified_issues: self.identify_validation_issues(&validation_results),
recommendations: self.generate_validation_recommendations(&validation_results),
}
}
fn test_adversarial_robustness(&self, response: &SpecialistResponse) -> f64 {
// Generate adversarial variations of the original query
let adversarial_queries = self.generate_adversarial_queries(&response.original_query);
let mut robustness_scores = Vec::new();
for adversarial_query in adversarial_queries {
// Get response to adversarial query
let adversarial_response = self.get_response_to_adversarial_query(&adversarial_query);
// Measure consistency with original response
let consistency = self.measure_response_consistency(response, &adversarial_response);
robustness_scores.push(consistency);
}
// Return average robustness score
robustness_scores.iter().sum::<f64>() / robustness_scores.len() as f64
}
}
Mzekezeke Integration - Belief Network Updates
impl DiadochiMzekezeketegration {
pub fn update_beliefs_with_expert_knowledge(&self, expert_responses: &[SpecialistResponse], belief_network: &mut BayesianNetwork) {
for response in expert_responses {
// Extract evidence from expert response
let evidence = self.extract_evidence_from_response(response);
// Assess evidence quality based on expert credibility
let evidence_quality = self.assess_evidence_quality(response, &evidence);
// Weight evidence by expert reliability
let expert_reliability = self.get_expert_reliability(&response.model_id);
let weighted_evidence = self.weight_evidence(evidence, expert_reliability, evidence_quality);
// Update belief network
belief_network.incorporate_evidence(weighted_evidence);
}
// Recalculate belief distributions
belief_network.update_beliefs();
}
fn assess_evidence_quality(&self, response: &SpecialistResponse, evidence: &Evidence) -> EvidenceQuality {
EvidenceQuality {
source_credibility: self.assess_source_credibility(response),
methodological_soundness: self.assess_methodology(response),
recency: self.assess_evidence_recency(evidence),
consistency_with_existing_beliefs: self.assess_consistency(evidence),
specificity: self.assess_evidence_specificity(evidence),
}
}
}
Cost Management and Optimization
Sophisticated cost management system for API usage:
pub struct CostManagementSystem {
budget_allocator: BudgetAllocator,
cost_predictor: CostPredictor,
roi_calculator: ROICalculator,
usage_optimizer: UsageOptimizer,
}
pub struct BudgetAllocation {
total_budget: f64,
per_domain_budgets: HashMap<Domain, f64>,
per_model_budgets: HashMap<ModelId, f64>,
emergency_reserve: f64,
cost_per_benefit_threshold: f64,
}
impl CostManagementSystem {
pub fn optimize_consultation_plan(&self, requirements: &[ExpertiseRequirement], budget: &BudgetAllocation) -> OptimizedConsultationPlan {
// Calculate expected ROI for each possible consultation
let consultation_options = self.generate_consultation_options(requirements);
let roi_scores: Vec<_> = consultation_options
.iter()
.map(|option| {
let expected_cost = self.cost_predictor.predict_cost(option);
let expected_benefit = self.roi_calculator.calculate_expected_benefit(option);
let roi = expected_benefit / expected_cost;
(option.clone(), expected_cost, expected_benefit, roi)
})
.collect();
// Use knapsack-style optimization to maximize ROI within budget
let optimized_plan = self.solve_consultation_optimization_problem(&roi_scores, budget);
OptimizedConsultationPlan {
selected_consultations: optimized_plan.consultations,
total_expected_cost: optimized_plan.cost,
total_expected_benefit: optimized_plan.benefit,
expected_roi: optimized_plan.benefit / optimized_plan.cost,
budget_utilization: optimized_plan.cost / budget.total_budget,
risk_assessment: self.assess_plan_risks(&optimized_plan),
}
}
pub fn real_time_cost_monitoring(&self, active_consultations: &[ActiveConsultation]) -> CostMonitoringReport {
let mut current_costs = 0.0;
let mut projected_costs = 0.0;
let mut cost_overruns = Vec::new();
for consultation in active_consultations {
let current_cost = consultation.calculate_current_cost();
let projected_cost = self.cost_predictor.project_final_cost(consultation);
current_costs += current_cost;
projected_costs += projected_cost;
// Check for cost overruns
if projected_cost > consultation.budgeted_cost * 1.1 {
cost_overruns.push(CostOverrun {
consultation_id: consultation.id.clone(),
budgeted_cost: consultation.budgeted_cost,
projected_cost,
overrun_percentage: (projected_cost / consultation.budgeted_cost - 1.0) * 100.0,
});
}
}
CostMonitoringReport {
current_total_cost: current_costs,
projected_total_cost: projected_costs,
cost_overruns,
budget_burn_rate: self.calculate_burn_rate(&active_consultations),
recommended_actions: self.generate_cost_recommendations(&active_consultations),
}
}
}
Performance Metrics and Evaluation
Comprehensive system for measuring Diadochi effectiveness:
pub struct DiadochiMetrics {
pub expertise_coverage_score: f64, // How well expert selection covers requirements
pub synthesis_quality_score: f64, // Quality of expert response synthesis
pub cost_efficiency_score: f64, // Value per dollar spent
pub response_time_score: f64, // Speed of expert consultation
pub accuracy_improvement_score: f64, // Accuracy vs single model
pub confidence_calibration_score: f64, // How well confidence matches accuracy
pub domain_specificity_score: f64, // How well experts match domain needs
pub consensus_achievement_score: f64, // Ability to reach expert consensus
}
impl DiadochiMetrics {
pub fn calculate_overall_effectiveness(&self) -> f64 {
let weights = [0.2, 0.2, 0.15, 0.1, 0.15, 0.1, 0.1];
let scores = [
self.expertise_coverage_score,
self.synthesis_quality_score,
self.cost_efficiency_score,
self.response_time_score,
self.accuracy_improvement_score,
self.confidence_calibration_score,
self.domain_specificity_score,
];
scores.iter()
.zip(weights.iter())
.map(|(score, weight)| score * weight)
.sum()
}
}
Turbulance Language Integration
Diadochi operations exposed through Turbulance:
// Basic expert consultation
item expert_response = consult_experts(text, domain="medical")
// Advanced multi-expert consultation
item collaboration_result = consult_experts(text, {
domains: ["legal", "financial", "regulatory"],
synthesis_strategy: "evidence_based",
budget_limit: 50.0,
confidence_requirement: 0.85
})
// Domain-specific routing
given text.contains_domain_indicators("genomics"):
item genomics_experts = route_to_domain("genomics", {
complexity_level: "high",
specializations: ["variant_interpretation", "population_genetics"],
evidence_level: "peer_reviewed"
})
// Cost-optimized consultation
item cost_optimized = consult_experts(text, {
optimization_target: "cost_efficiency",
max_cost: 25.0,
min_quality: 0.8,
preferred_providers: ["huggingface", "openai"]
})
// Integration with existing modules
given spectacular.is_extraordinary(text):
// Use premium experts for extraordinary content
item premium_consultation = consult_experts(text, {
expert_tier: "premium",
budget_multiplier: 3.0,
synthesis_strategy: "expert_debate",
validation_level: "rigorous"
})
// Real-time collaboration
flow expert_session on complex_problem:
item initial_consultation = consult_experts(expert_session.current_question)
given initial_consultation.consensus_score < 0.7:
// Facilitate expert debate for low consensus
item debate_result = facilitate_expert_debate(
experts: initial_consultation.participating_experts,
rounds: 3,
convergence_threshold: 0.8
)
expert_session.update_with_debate_result(debate_result)
otherwise:
expert_session.accept_consensus(initial_consultation)
Diadochi represents a paradigm shift in how AI systems access and utilize expertise, transforming the limitations of any single model into the collaborative intelligence of specialist expert networks. By intelligently orchestrating domain expertise and synthesizing multiple expert perspectives, it creates a system that truly embodies the principle that “the whole is greater than the sum of its parts.”