Skip to content

Refactor ModelType Enum to Extensible Interface-Based #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2025

Conversation

koosty
Copy link
Contributor

@koosty koosty commented Jun 20, 2025

Hey, I’ve been messing around with this project and ran into a snag—I can’t easily add my own custom models. The LLM model structure’s a bit tricky for me to wrap my head around, so I’m not super comfy trying to add new models myself. It’d be awesome if there was a way for users to drop in their own models without waiting for official support.

Description

This PR refactors the ModelType enum to an interface to make it extensible allowing new model types to be added without modifying existing code.

Motivation

New model types can be added via new ModelType implementations and registered without changing existing code.

ModelSupport.ModelType modelType = new ModelSupport.ModelType() {
    @Override
    public Class<? extends AbstractModel> getModelClass() {
        return Qwen2Model.class;
    }
    @Override
    public Class<? extends Config> getConfigClass() {
        return Qwen2Config.class;
    }
    @Override
    public Class<? extends Tokenizer> getTokenizerClass() {
        return LlamaTokenizer.class;
    }
};

ModelSupport.register("QWEN3", modelType);
AbstractModel model = ModelSupport.loadEmbeddingModel(new File("Qwen_Qwen3-Embedding-0.6B"), DType.F32, DType.I8);

…extensible

allowing new model types to be added without modifying existing code
Copy link
Owner

@tjake tjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool idea, thank you!

@tjake tjake merged commit 9a8212d into tjake:main Jun 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants