Skip to content

elm/domain_elm.hpp

Domain ELM — optional dedicated model with shared-backbone fallback. More...

Namespaces

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

Classes

Name
class sgns::neoswarm::elm::DomainELM
Domain-specific ELM (Math, Code, Science) with optional dedicated .mnn model file.

Detailed Description

Domain ELM — optional dedicated model with shared-backbone fallback.

Date: 2026-07-16

Source code

#ifndef NEOSWARM_ELM_DOMAIN_ELM_HPP
#define NEOSWARM_ELM_DOMAIN_ELM_HPP

#include "i_elm.hpp"
#include "core/engine/inference_engine.hpp"

#include <memory>
#include <string>

namespace sgns::neoswarm::elm
{
    class DomainELM : public IELM
    {
        public:
        explicit DomainELM( ELMRole role, std::shared_ptr<core::InferenceEngine> sharedEngine = nullptr );

        std::string GetName() const override
        {
            return m_name;
        }
        ELMRole GetRole() const override
        {
            return m_role;
        }
        bool IsLoaded() const override
        {
            return m_loaded;
        }

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

        // GetConfidence() inherited from IELM — m_lastConfidence is set in Process()

        private:
        ELMRole m_role;
        std::string m_name;
        std::shared_ptr<core::InferenceEngine> m_sharedEngine;
        std::unique_ptr<core::InferenceEngine> m_ownEngine;
        bool m_loaded = false;
        bool m_ownsEngine = false;

        std::string BuildPrompt( const std::string& input, const ELMContext& context ) const;

        core::InferenceEngine* SelectEngine() const noexcept;
    };

} // namespace sgns::neoswarm::elm

#endif // NEOSWARM_ELM_DOMAIN_ELM_HPP

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