|
| 1 | +import { DeviceType } from "./Runtime"; |
| 2 | + |
| 3 | +// Precision data types distributed as a union |
| 4 | +export type _FullPrecisionDType = 'fp32'; |
| 5 | +export type _HalfPrecisionDType = 'fp16'; |
| 6 | +export type _8BitPrecisionDType = 'q8' | 'in8' | 'uint8'; |
| 7 | +export type _4BitPrecisionDType = 'q4' | 'bnb4' | 'q4f16'; |
| 8 | + |
| 9 | +// Combine into a full union |
| 10 | +export type DType = _FullPrecisionDType | _HalfPrecisionDType | _8BitPrecisionDType | _4BitPrecisionDType; |
| 11 | + |
| 12 | +/** |
| 13 | + * Device configuration |
| 14 | + */ |
| 15 | +export interface DeviceConfig { |
| 16 | + device?: DeviceType; |
| 17 | + dtype?: DType; |
| 18 | +} |
| 19 | + |
| 20 | +/** |
| 21 | + * Task type for the models |
| 22 | + */ |
| 23 | +type TaskType = |
| 24 | +'text-generation' |
| 25 | +| 'embedding-generation' |
| 26 | +| 'text-to-speech' |
| 27 | +| 'speech-to-text' |
| 28 | + |
| 29 | +/** |
| 30 | + * Interface for the model |
| 31 | + */ |
| 32 | +export interface Model { |
| 33 | + repository: string, |
| 34 | + quantization: DType, |
| 35 | + taskType: TaskType, |
| 36 | + [key: string]: string, |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * Interfaces for supported models |
| 41 | + */ |
| 42 | +type LanguageModelsType = |
| 43 | +'onnx-community/DeepSeek-R1-Distill-Qwen-1.5B-ONNX' |
| 44 | +| 'onnx-community/Llama-3.2-1B-Instruct-q4f16' |
| 45 | +| 'HuggingFaceTB/SmolLM2-1.7B-Instruct' |
| 46 | + |
| 47 | +type VisionLanguageModelsType = |
| 48 | +'HuggingFaceTB/SmolVLM-256M-Instruct' |
| 49 | + |
| 50 | +type TextEmbeddingModelsType = |
| 51 | +'nomic-ai/nomic-embed-text-v1.5' |
| 52 | + |
| 53 | +type MultiModalEmbeddingModelsType = |
| 54 | +'jinaai/jina-clip-v1' |
| 55 | + |
| 56 | +type TextToSpeechModelsType = |
| 57 | +'onnx-community/Kokoro-82M-v1.0-ONNX' |
| 58 | + |
| 59 | +type SpeechToTextModelsType = |
| 60 | +'onnx-community/moonshine-base-ONNX' |
| 61 | +| 'onnx-community/whisper-tiny.en' |
| 62 | + |
| 63 | +/** |
| 64 | + * Models Natively Supported by TinyLM |
| 65 | + */ |
| 66 | +type SupportedModelsType = LanguageModelsType | VisionLanguageModelsType | TextEmbeddingModelsType | MultiModalEmbeddingModelsType | TextToSpeechModelsType | SpeechToTextModelsType |
| 67 | + |
| 68 | +type ModelCatalogType = Record<SupportedModelsType, Model> |
| 69 | + |
| 70 | + |
| 71 | +/** |
| 72 | + * Model Catalog - Maps all supported models to their configurations |
| 73 | + */ |
| 74 | +export const modelCatalog: ModelCatalogType = { |
| 75 | + // Language Models |
| 76 | + "onnx-community/DeepSeek-R1-Distill-Qwen-1.5B-ONNX": { |
| 77 | + repository: "onnx-community/DeepSeek-R1-Distill-Qwen-1.5B-ONNX", |
| 78 | + quantization: "fp16", |
| 79 | + taskType: "text-generation", |
| 80 | + }, |
| 81 | + "onnx-community/Llama-3.2-1B-Instruct-q4f16": { |
| 82 | + repository: "onnx-community/Llama-3.2-1B-Instruct-q4f16", |
| 83 | + quantization: "q4f16", |
| 84 | + taskType: "text-generation", |
| 85 | + }, |
| 86 | + "HuggingFaceTB/SmolLM2-1.7B-Instruct": { |
| 87 | + repository: "HuggingFaceTB/SmolLM2-1.7B-Instruct", |
| 88 | + quantization: "q8", |
| 89 | + taskType: "text-generation", |
| 90 | + }, |
| 91 | + |
| 92 | + // Vision Language Models |
| 93 | + "HuggingFaceTB/SmolVLM-256M-Instruct": { |
| 94 | + repository: "HuggingFaceTB/SmolVLM-256M-Instruct", |
| 95 | + quantization: "fp16", |
| 96 | + taskType: "text-generation", |
| 97 | + }, |
| 98 | + |
| 99 | + // Text Embedding Models |
| 100 | + "nomic-ai/nomic-embed-text-v1.5": { |
| 101 | + repository: "nomic-ai/nomic-embed-text-v1.5", |
| 102 | + quantization: "fp32", |
| 103 | + taskType: "embedding-generation", |
| 104 | + }, |
| 105 | + |
| 106 | + // Multi-Modal Embedding Models |
| 107 | + "jinaai/jina-clip-v1": { |
| 108 | + repository: "jinaai/jina-clip-v1", |
| 109 | + quantization: "fp16", |
| 110 | + taskType: "embedding-generation", |
| 111 | + }, |
| 112 | + |
| 113 | + // Text-to-Speech Models |
| 114 | + "onnx-community/Kokoro-82M-v1.0-ONNX": { |
| 115 | + repository: "onnx-community/Kokoro-82M-v1.0-ONNX", |
| 116 | + quantization: "fp32", |
| 117 | + taskType: "text-to-speech", |
| 118 | + }, |
| 119 | + |
| 120 | + // Speech-to-Text Models |
| 121 | + "onnx-community/moonshine-base-ONNX": { |
| 122 | + repository: "onnx-community/moonshine-base-ONNX", |
| 123 | + quantization: "fp16", |
| 124 | + taskType: "speech-to-text", |
| 125 | + }, |
| 126 | + "onnx-community/whisper-tiny.en": { |
| 127 | + repository: "onnx-community/whisper-tiny.en", |
| 128 | + quantization: "q8", |
| 129 | + taskType: "speech-to-text", |
| 130 | + } |
| 131 | +} |
0 commit comments