Expand description
Path Quality Computation
Implements TPO (Topological Preference Optimization) path quality scoring for enhanced salience computation. Quality measures how “good” a conversation path is, which helps weight turns within that path.
§Path Quality Formula
Q(P) = α·L(P) + β·T(P) + γ·S(P) + δ·C(P)| Factor | Formula | Meaning | Default Weight |
|---|---|---|---|
| L(P) | 1 - var(depth_changes) | Linearity - smooth depth progression | α = 0.25 |
| T(P) | terminal_node_score | Terminal quality - how path ends | β = 0.30 |
| S(P) | mean(homogeneity) | Semantic coherence along path | γ = 0.25 |
| C(P) | path_length / max_length | Completion - path reaches conclusion | δ = 0.20 |
§Usage
use rag_plusplus_core::trajectory::{PathQuality, PathQualityWeights, PathQualityFactors};
// Compute factors for a path
let factors = PathQualityFactors::from_path_data(
&[1, 2, 3, 4], // depths along path
&[0.9, 0.85, 0.8, 0.75], // homogeneity values
5, // max possible depth
true, // is terminal
0.8, // terminal score if terminal
);
// Compute quality score with default weights
let quality = factors.compute_quality(&PathQualityWeights::default());
// Use for salience enhancement
let base_salience = 0.5;
let enhanced_salience = PathQuality::enhance_salience(base_salience, quality, 0.3);Structs§
- Path
Quality - Path quality utilities.
- Path
Quality Factors - Computed path quality factors.
- Path
Quality Weights - Weights for path quality components.