You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
epic: Implement new Model Folder and model.yaml #1154
Model detection should not depend on model folder?
Model detection depends on the model folder, which would introduce performance issues since:
Every time the app loads, it needs to scan through the model folder hierarchy.
Costly filesystem watching (Notify the app of changes)
This means we likely depend on the manifest file, where it is the source of trust, as it links to all available models with different folder structures.
This introduces a periodically scanning folder watchdog. A delay problem may occur.
Everything just works with references or symlinks.
Structures do not work well in the past or I have seen around:
1. Shallow structure
All of the YAML files are placed in the root of the directory.
Pros: Fast lookup - just filter out YAML files from the root folder to list models.
Cons: Easy to duplicate, cannot work with different model families. Same name for different branches/authors/engines.
Slower over time since n models = 2n items. 2 rm operations to remove a model.
E.g. llama3 of cortexhub | gguf | Q4 | Q8 | onnx | thebloke
At each individual level of the sources hierarchy, all options are different responses to the same question: What hub is the source? What repo is in the hub? What model types are supported in the repo? What branch is the model pulled from? What model and what quantization are pulled?
model.yaml files are flattened for quick search in the metadatas so users can easily find the one they want to edit, which boosts the performance of model listing. The filename is a normalized form of model_id.
From the sources folder hierarchy, we can determine the author andformat | engine, so we can get rid of model.yaml's redundant fields. The 'engine' should not be in model.yaml since it's not related to the model (application level) and cannot be reused across applications.
Files are organized differently in different domains (metadatas / sources).
Everything is a symlink, from [model].yaml, we can retrieve the source hierarchies.
Manifest is for caching (optional), which can improve UX and boost performance. This allows us to avoid including all computed fields (such as decorations, sorting order - drag and drop later, or sorting results) in model.yaml (e.g., size, quantization). These fields are not essential when constructing or modifying model.yaml, but they do increase the risk of errors. Since they can be retrieved from the source files, we only need to cache them when populating the model.
Unified model's URL - Determine whether the model is downloaded or not, the local URL and remote URL are quite messy (before file:// and https://). With that model folder hierarchy we can just use 1 universal URL for both. E.g. models://huggingface/bartowski/Mixtral-8x22B-v0.1/main/Mixtral-8x22B-v0.1-IQ3_M-00001-of-00005.gguf.
ALTERNATIVE PATH:
Inspired by /etc/apt/sources.list
I'm still thinking about another path that could address a couple of problems that arise from the structure above where:
model.yaml file name can be duplicated
An unique model id should be autogenerated somehow. If generate using folder path, it should be where model.yaml is located not the source file. So model.yaml could not be flattened. (might be there is another option that can generate a human readable model name).
Less complex structure
Inspired by the PPA repositories list mechanism. This approach simply put all of the model files in a sources.list. So app can list all of the nested model.yaml without worrying about the performance issue. Also can use any editor to Ctrl + Click to open model.yaml file. (previously I find it hard to look up a model.yaml in a nested model folder)
But there is also a con where users could not search or view a model folder file without opening the sources.list using an external editor.
To me, a clean and functioning focused model.yaml file should follow these principles:
1. Build for Functionality, Not Decoration The model.yaml file is built to define core functionalities of the app rather than superficial decorations.
Its primary role is to allow users to configure advanced model and inference settings, giving them the ability to control and fine-tune how the app interacts with the model. For instance, in cases where legacy models lack certain parameters metadata, maintainers or users can easily edit and update the configuration.
2. Model Configuration, Not App Caching or Storage The file serves as a configuration file for controlling requests and managing model behaviors.
It is not intended for managing app caching, storage, or persistence layers. All fields must be relevant to controlling the model’s interaction and performance.
3. Unified Structure for Public Sharing and Best Practices The model.yaml follows a unified structure that aims to create a standard practice among authors and developers.
This structure encourages the publishing and sharing of model configuration settings for various use cases, creating a community-driven trend where the best configurations for different tasks and models are easily accessible.
The model.yaml would be similar to this
# BEGIN GENERAL GGUF METADATAmodel: gemma-2-9b-it-Q8_0 # Model ID which is used for request construct - should be unique between models (author / quantization)name: Llama 3.1 # metadata.general.nameversion: 1# metadata.versionsources: # can be universal protocol (models://) OR absolute local file path (file://) OR https remote URL (https://)
- models://huggingface/bartowski/Mixtral-8x22B-v0.1/main/Mixtral-8x22B-v0.1-IQ3_M-00001-of-00005.gguf
- models://huggingface/bartowski/Mixtral-8x22B-v0.1/main/Mixtral-8x22B-v0.1-IQ3_M-00002-of-00005.gguf# END GENERAL GGUF METADATA# BEGIN INFERENCE PARAMETERS# BEGIN REQUIREDstop: # tokenizer.ggml.eos_token_id - <|end_of_text|> - <|eot_id|> - <|eom_id|># END REQUIRED# BEGIN OPTIONALstream: true # Default true?top_p: 0.9# Ranges: 0 to 1temperature: 0.6# Ranges: 0 to 1frequency_penalty: 0# Ranges: 0 to 1presence_penalty: 0# Ranges: 0 to 1max_tokens: 8192# Should be default to context length# END OPTIONAL# END INFERENCE PARAMETERS# BEGIN MODEL LOAD PARAMETERS# BEGIN REQUIREDprompt_template: |+ # tokenizer.chat_template <|begin_of_text|><|start_header_id|>system<|end_header_id|> {system_message}<|eot_id|><|start_header_id|>user<|end_header_id|> {prompt}<|eot_id|><|start_header_id|>assistant<|end_header_id|># END REQUIRED# BEGIN OPTIONALctx_len: 0# llama.context_length | 0 or undefined = loaded from modelngl: 33# Undefined = loaded from model# END OPTIONAL# END MODEL LOAD PARAMETERS
As described before, other fields like author or engine could be determined by the model folder, or cortex.cpp can detect the model file type.
We should use the term model since it's consolidated, whereas id is quite server/system specific and not directly related to the LLM model.
The model value could be generated in case we run local models. It's a DTO property rather than stored property, since it is only used to determine what model (actually from which model is running from what folder path). Overwrite model from model.yaml file is to prevent auto generated mechanism which would work for remote models. E.g. openai/gpt-3.5-turbo.
Model sources/files is a messy issue, where the program does not know the model is downloaded or not, what is the correct downloaded path, what is the remote path (to redownload). So I really like to use this universal source protocol where:
models://[hub]/[author]/[repo]/[branch]/[file] which present a remote file URL can be downloaded into the models folder. The logic is to check the file exist following a constructed local file path or download from a constructed remote path built from the universal path.
Activity
[-]epic: Model Folder finalize structure[/-][+]epic: Finalize how Model Folder and model.yaml works[/+]freelerobot commentedon Sep 9, 2024
Legacy model folder structure: janhq/jan#3541 (comment)
louis-jan commentedon Sep 10, 2024
Model detection should not depend on model folder?
Model detection depends on the model folder, which would introduce performance issues since:
This means we likely depend on the manifest file, where it is the source of trust, as it links to all available models with different folder structures.
Structures do not work well in the past or I have seen around:
1. Shallow structure
All of the YAML files are placed in the root of the directory.
Pros: Fast lookup - just filter out YAML files from the root folder to list models.
Cons: Easy to duplicate, cannot work with different model families. Same name for different branches/authors/engines.
Slower over time since
n models = 2n items. 2rmoperations to remove a model.E.g. llama3 of cortexhub | gguf | Q4 | Q8 | onnx | thebloke
2. One level of deep structure
All files are placed in a model folder.
Pros: Easy to manage model by model, 1
rmoperation can remove the entire model folder.Cons: Slow list iteration, the app has to loop through every single folder and check if the model file exists. So many FS operations.
Getting our Filesystem hierarchy less wrong with these 3 following Principles:
Principle 1: The Single-Question Principle
At each level of the hierarchy, strive to make all folder names answer the same question.
Principle 2: The Domain Principle
Organize files in different domains differently.
Principle 3: The Depth Principle
Prefer deep hierarchies over shallow ones.
The structures would be similar to this:
OR
sourceshierarchy, all options are different responses to the same question: Whathubis thesource? Whatrepois in thehub? Whatmodel typesare supported in therepo? Whatbranchis themodelpulled from? Whatmodeland whatquantizationare pulled?model.yamlfiles are flattened for quick search in themetadatasso users can easily find the one they want to edit, which boosts the performance of model listing. Thefilenameis a normalized form ofmodel_id.authorandformat | engine, so we can get rid ofmodel.yaml's redundant fields. The'engine'should not be inmodel.yamlsince it's not related to the model (application level) and cannot be reused across applications.Filesare organized differently in different domains (metadatas/sources).sourcehierarchies.models://huggingface/bartowski/Mixtral-8x22B-v0.1/main/Mixtral-8x22B-v0.1-IQ3_M-00001-of-00005.gguf.ALTERNATIVE PATH:
Inspired by /etc/apt/sources.list
I'm still thinking about another path that could address a couple of problems that arise from the structure above where:
Inspired by the PPA repositories list mechanism. This approach simply put all of the model files in a
sources.list. So app can list all of the nested model.yaml without worrying about the performance issue. Also can use any editor to Ctrl + Click to open model.yaml file. (previously I find it hard to look up a model.yaml in a nested model folder)But there is also a con where users could not search or view a model folder file without opening the sources.list using an external editor.
Design model.yaml structure
To me, a clean and functioning focused
model.yamlfile should follow these principles:1. Build for Functionality, Not Decoration
The
model.yamlfile is built to define core functionalities of the app rather than superficial decorations.Its primary role is to allow users to configure advanced model and inference settings, giving them the ability to control and fine-tune how the app interacts with the model. For instance, in cases where legacy models lack certain parameters metadata, maintainers or users can easily edit and update the configuration.
2. Model Configuration, Not App Caching or Storage
The file serves as a configuration file for controlling requests and managing model behaviors.
It is not intended for managing app caching, storage, or persistence layers. All fields must be relevant to controlling the model’s interaction and performance.
3. Unified Structure for Public Sharing and Best Practices
The
model.yamlfollows a unified structure that aims to create a standard practice among authors and developers.This structure encourages the publishing and sharing of model configuration settings for various use cases, creating a community-driven trend where the best configurations for different tasks and models are easily accessible.
The model.yaml would be similar to this
As described before, other fields like
authororenginecould be determined by the model folder, or cortex.cpp can detect the model file type.We should use the term
modelsince it's consolidated, whereasidis quite server/system specific and not directly related to the LLM model.The
modelvalue could be generated in case we run local models. It's a DTO property rather than stored property, since it is only used to determine what model (actually from which model is running from what folder path). Overwritemodelfrom model.yaml file is to prevent auto generated mechanism which would work for remote models. E.g.openai/gpt-3.5-turbo.Model sources/files is a messy issue, where the program does not know the model is downloaded or not, what is the correct downloaded path, what is the remote path (to redownload). So I really like to use this universal source protocol where:
models://[hub]/[author]/[repo]/[branch]/[file]which present a remote file URL can be downloaded into the models folder. The logic is to check the file exist following a constructed local file path or download from a constructed remote path built from the universal path.cc @dan-homebrew @0xSage
23 remaining items
dan-menlo commentedon Sep 27, 2024
@nguyenhoangthuan99 I am shifting this to @vansangpfiev and tracking Tasklist items, just to keep big picture sitpic of progress.