Skip to content

elm/grounding_elm.hpp

GroundingELM — wraps the 3-stage knowledge pipeline behind IELM (D-17) More...

Namespaces

Name
sgns
sgns::neoswarm
sgns::neoswarm::elm

Classes

Name
class sgns::neoswarm::elm::GroundingELM
ELM that grounds responses against the Grokipedia knowledge base.

Detailed Description

GroundingELM — wraps the 3-stage knowledge pipeline behind IELM (D-17)

Date: 2026-07-17

Source code

#ifndef NEOSWARM_ELM_GROUNDING_ELM_HPP
#define NEOSWARM_ELM_GROUNDING_ELM_HPP

#include "i_elm.hpp"
#include "core/engine/inference_engine.hpp"
#include "knowledge/knowledge_retrieval.hpp"
#include "knowledge/context_injection.hpp"
#include "knowledge/fact_validation.hpp"

#include <memory>
#include <string>

namespace sgns::neoswarm::elm
{
    class GroundingELM : public IELM
    {
        public:
        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 );

        std::string GetName() const override
        {
            return "Grounding";
        }

        ELMRole GetRole() const override
        {
            return ELMRole::Grounding;
        }

        bool IsLoaded() const override
        {
            return m_loaded;
        }

        float GetConfidence() const override
        {
            return m_lastConfidence;
        }

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

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

        private:
        std::shared_ptr<core::InferenceEngine> m_engine;
        std::shared_ptr<knowledge::KnowledgeRetrieval> m_knowledge;
        std::unique_ptr<knowledge::ContextInjection> m_contextInj;
        std::unique_ptr<knowledge::FactValidation> m_factVal;
        bool m_loaded = false;
        float m_lastConfidence = 0.0f;
    };

} // namespace sgns::neoswarm::elm

#endif // NEOSWARM_ELM_GROUNDING_ELM_HPP

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