Skip to content

sgns::neoswarm::elm::GroundingELM

ELM that grounds responses against the Grokipedia knowledge base. More...

#include <grounding_elm.hpp>

Inherits from sgns::neoswarm::elm::IELM

Public Functions

Name
GroundingELM(std::shared_ptr< core::InferenceEngine > engine, std::shared_ptr< knowledge::KnowledgeRetrieval > knowledge, std::unique_ptr< knowledge::ContextInjection > contextInj, std::unique_ptr< knowledge::FactValidation > factVal)
Construct a GroundingELM with the full knowledge pipeline.
virtual std::string GetName() const override
virtual ELMRole GetRole() const override
virtual bool IsLoaded() const override
virtual float GetConfidence() const override
Confidence in the last Process() call.
virtual outcome::result< void > Load(const std::string & model_path) override
Load the ELM model from disk (if a dedicated model path is configured).
virtual outcome::result< std::string > Process(const std::string & input, const ELMContext & context) override
Process input through this ELM and return refined output.

Additional inherited members

Public Functions inherited from sgns::neoswarm::elm::IELM

Name
virtual ~IELM() =default

Detailed Description

class sgns::neoswarm::elm::GroundingELM;

ELM that grounds responses against the Grokipedia knowledge base.

Implements a 4-stage pipeline per D-17:

  1. Retrieve — query knowledge base for relevant facts
  2. Inject — augment the prompt with retrieved facts
  3. Infer — run inference on the augmented prompt
  4. Validate — check output against grounding facts, adjust confidence

If the knowledge pipeline is unavailable, the ELM returns input unchanged with zero confidence (fail-close pattern).

Public Functions Documentation

function GroundingELM

GroundingELM(
    std::shared_ptr< core::InferenceEngine > engine,
    std::shared_ptr< knowledge::KnowledgeRetrieval > knowledge,
    std::unique_ptr< knowledge::ContextInjection > contextInj,
    std::unique_ptr< knowledge::FactValidation > factVal
)

Construct a GroundingELM with the full knowledge pipeline.

Parameters:

  • engine Shared inference engine for stage 3.
  • knowledge Knowledge retrieval backend for stage 1.
  • contextInj Context injection for stage 2.
  • factVal Fact validation for stage 4.

function GetName

inline virtual std::string GetName() const override

Return: Human-readable name of this ELM.

Reimplements: sgns::neoswarm::elm::IELM::GetName

function GetRole

inline virtual ELMRole GetRole() const override

Return: The ELM role this instance fulfills.

Reimplements: sgns::neoswarm::elm::IELM::GetRole

function IsLoaded

inline virtual bool IsLoaded() const override

Return: True if the ELM model has been loaded.

Reimplements: sgns::neoswarm::elm::IELM::IsLoaded

function GetConfidence

inline virtual float GetConfidence() const override

Confidence in the last Process() call.

Return: Confidence score in [0, 1].

Reimplements: sgns::neoswarm::elm::IELM::GetConfidence

Default implementation returns a protected m_lastConfidence field. RoleELM and DomainELM set this in Process() and inherit the getter. Specialists that use the adapter pattern override for legacy ISpecialist.

function Load

virtual outcome::result< void > Load(
    const std::string & model_path
) override

Load the ELM model from disk (if a dedicated model path is configured).

Parameters:

  • model_path Path to the model file (.mnn or similar).

Return: outcome::success or ModelLoadFailed.

Reimplements: sgns::neoswarm::elm::IELM::Load

function Process

virtual outcome::result< std::string > Process(
    const std::string & input,
    const ELMContext & context
) override

Process input through this ELM and return refined output.

Parameters:

  • input Text to process (typically output of previous chain step).
  • context ELM execution context (original task, prior outputs, confidences).

Return: Refined text or InferenceFailed.

Reimplements: sgns::neoswarm::elm::IELM::Process


Updated on 2026-10-09 at 03:59:42 +0000