Skip to main content

Module semantic_coherence

Module semantic_coherence 

Source
Expand description

Semantic coherence scoring for BAR-RAG Semantic Coherence Scoring for Boundary-Aware Chunking

This module implements semantic coherence analysis using sentence embeddings to optimize chunk boundaries for maximum semantic unity.

Key capabilities:

  • Cosine similarity calculation between sentence embeddings
  • Intra-chunk coherence scoring
  • Optimal split-point detection via binary search
  • Adaptive threshold based on embedding distances

§References

  • BAR-RAG Paper: “Boundary-Aware Retrieval-Augmented Generation”
  • Target: +40% semantic coherence improvement

Structs§

CoherenceConfig
Configuration for semantic coherence scoring
OptimalSplit
Result of split-point optimization
ScoredChunk
Represents a candidate chunk with coherence score
SemanticCoherenceScorer
Semantic coherence scorer using sentence embeddings