Skip to content

Model constants grouped by type #612

Closed

Description

@a-szymanska

Problem description

Currently, the model constants don’t give much intuition about what each model is for, and so users need to reference documentation to know which models are available and what they’re used for. This problem also extends to Hugging Face, where models are listed ungrouped.

Proposed solution

  • Prefix names with model categories - maybe similar to how it is done in style transfer.
  • On Hugging Face, create collections that group models by the hook/module they are designed for.
    Then in the hook docs, we could replace links to specific models with links to the related collection, so users can easily browse all supported models for that hook.

Alternative solutions

Add JSDoc to model constants.

Benefits to React Native ExecuTorch

Users would be able to quickly identify what a model does without looking up the docs. This would reduce confusion and improve developer experience.

Additional context

No response

Activity

  1. added theissue type on Sep 18, 2025
  2. added
    modelIssues related to exporting, improving, fixing ML models
    huggingfaceIssues and tasks related to HuggingFace repository
    and removed on Oct 6, 2025
  3. msluszniak commented on Feb 2, 2026

    @msluszniak
    Member

    I don't think it is possible to create such code that will so intuitive here, so user could refer to a model without even looking once into documentation. The PR #748 adds organised section of models for each task, links it clearly in documentation. This way it solves the mentioned problem in a different way. That's why I will mark it for resolving by the PR.

  4. msluszniak commented on Feb 2, 2026

    @msluszniak
    Member

    The is an idea to not only suggest list of models from documentation, but also from the level of language server (e.g. tabbing in VSC). The proposed solution might look like this:

    import { MODELS_REGISTRY } from "react-native-executorch;"
    
    const llm = useLLM({ MODELS_REGISTRY.LLM.SOME_MODEL })
  5. mkopcins commented on Mar 25, 2026

    @mkopcins
    Collaborator

    The final approach would be as follows:

    1. internally we maintain model map will following structure:
    const MODEL_MAP = {
      LLM: {
        LLAMA3_2_1B: {
          'base': {
            'xnnpack': LLAMA3_2_1B
          },
          'qlora': {
            'xnnpack': LLAMA3_2_1B_QLORA
          },
          'spinquant': LLAMA3_2_1B_SPINQUANT
        },
        QWEN2_5_0_5B: {
          'base': {
            'xnnpack': QWEN2_5_0_5B
          },
          '8dw4a': {
            'xnnpack': QWEN2_5_0_5B_QUANTIZED
          }
        },
        ...
      }
    };
    
    1. we export public model registry
    export const MODEL_REGISTRY = {
      LLM: {
        LLAMA3_2_1B: modelAccessor(
          LLAMA3_2_1B,
          ({
            quant = 'base',
            backend = 'xnnpack',
          }: {
            quant?: 'base' | 'qlora' | 'spinquant';
            backend?: 'xnnpack';
          } = {}) => MODEL_MAP.LLM.LLAMA3_2_1B[quant][backend]
        ),
        QWEN2_5_0_5B: modelAccessor(
          QWEN2_5_0_5B,
          ({
            quant = 'base',
            backend = 'xnnpack',
          }: {
            quant?: 'base' | '8da4w';
            backend?: 'xnnpack';
          } = {}) => MODEL_MAP.LLM.QWEN2_5_0_5B[quant][backend]
        ),
      },
    };
    
    function modelAccessor<T extends Record<string, unknown>>(
      defaultValue: T,
      fn: (opts?: any) => T
    ): T & ((opts?: any) => T) {
      return new Proxy(fn, {
        get(_target, prop) {
          return (defaultValue as any)[prop];
        },
      }) as T & ((opts?: any) => T);
    }
    

    With this we achieve following:

    1. Default models:
    MODEL_REGISTRY.LLM.LLAMA3_2_1B
    
    1. Select a model
    MODEL_REGISTRY.LLM.LLAMA3_2_1B({quant: 'spinquant', backend: 'xnnpack'});
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

huggingfaceIssues and tasks related to HuggingFace repositorymodelIssues related to exporting, improving, fixing ML models

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions