Skip to content

Commit

Permalink
Merge pull request #61 from krai/better_llm_downloading
Browse files Browse the repository at this point in the history
Better llm model/tokeniser downloading
  • Loading branch information
Akshat-Tripathi authored Oct 24, 2024
2 parents 19a5c6a + c9a7c5a commit 042dd3a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 105 deletions.
4 changes: 1 addition & 3 deletions data_axs.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@
"moe_reference_using_torch_loadgen": "moe_reference_using_torch_loadgen",
"llm_hf_weights_recipe": "llm_hf_weights_recipe",
"huggingface_tool_detector": "huggingface_tool_detector",
"model_llama3_recipe": "model_llama3_recipe",
"model_training_llama2_recipe": "model_training_llama2_recipe",
"dataset_scrolls_gov_report_8k_recipe": "dataset_scrolls_gov_report_8k_recipe",
"rclone_mlc_llama2_config": "rclone_mlc_llama2_config",
"model_llama3_1_recipe": "model_llama3_1_recipe"
"rclone_mlc_llama2_config": "rclone_mlc_llama2_config"
},
"repo_name": "axs2mlperf",
"submodules": false
Expand Down
13 changes: 13 additions & 0 deletions llm_hf_weights_recipe/code_axs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def get_model_info(model_family, variant, model_family_information=None, __entry__=None):
model_info = model_family_information[model_family]

assert "name_format" in model_info, f"Model family {model_family} has no \"name_format\" field"
assert "model_publisher" in model_info, f"Model family {model_family} has no \"model_publisher\" field"
assert "allowed_variants" in model_info, f"Model family {model_family} has no \"allowed_variants\" field"

assert variant in model_info["allowed_variants"], f"Cannot find {model_family}-{variant}"

return {
"model_name": __entry__.substitute(model_info["name_format"]),
"model_publisher": model_info["model_publisher"]
}
66 changes: 38 additions & 28 deletions llm_hf_weights_recipe/data_axs.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
{
"_parent_entries": [ [ "^", "byname", "downloader" ] ],
"_producer_rules": [
[ [ "downloaded", "hf_model", "model_family=llama2" ], [["get_kernel"],["byname","downloader"],["download"]], {
"downloading_tool_query": [ "AS^IS", "^^", "substitute", "shell_tool,can_download_url_from_huggingface,hf_token=#{hf_token}#" ],
"model_publisher": "meta-llama",
"model_name": [ "AS^IS", "^^", "substitute", "Llama-2-#{variant}#-chat-hf" ],
[ [ "downloaded", "hf_model" ], [["download"]], {
"type": "model"
}, ["url", "newborn_entry_name", "uncompressed_split_file_path" ] ],
[ [ "downloaded", "hf_tokeniser", "model_family=llama2" ], [["get_kernel"],["byname","downloader"],["download"]], {
"downloading_tool_query": [ "AS^IS", "^^", "substitute", "shell_tool,can_download_url_from_huggingface,hf_token=#{hf_token}#" ],
"model_publisher": "meta-llama",
"model_name": [ "AS^IS", "^^", "substitute", "Llama-2-#{variant}#-chat-hf" ],
"downloading_tool_cmd_key": "dload_tokeniser",
"type": "tokeniser"
}, ["url", "newborn_entry_name", "uncompressed_split_file_path" ] ],
[ [ "downloaded", "hf_tokeniser", "model_family=llama3" ], [["get_kernel"],["byname","downloader"],["download"]], {
"downloading_tool_query": [ "AS^IS", "^^", "substitute", "shell_tool,can_download_url_from_huggingface,hf_token=#{hf_token}#" ],
"model_publisher": "meta-llama",
"model_name": [ "AS^IS", "^^", "substitute", "Meta-Llama-3-8B" ],
"downloading_tool_cmd_key": "dload_tokeniser",
"type": "tokeniser"
}, ["url", "newborn_entry_name", "uncompressed_split_file_path" ] ],
[ [ "downloaded", "hf_tokeniser", "model_family=mixtral", "variant=8x7b" ], [["get_kernel"],["byname","downloader"],["download"]], {
"downloading_tool_query": [ "AS^IS", "^^", "substitute", "shell_tool,can_download_url_from_huggingface,hf_token=#{hf_token}#" ],
"model_publisher": "mistralai",
"model_name": "Mixtral-8x7B-Instruct-v0.1",
"downloading_tool_cmd_key": "dload_tokeniser",
"type": "tokeniser"
}, ["url", "newborn_entry_name", "uncompressed_split_file_path" ] ]
} ],
[ [ "downloaded", "hf_tokeniser" ], [["download"]], {
"type": "tokeniser",
"downloading_tool_cmd_key": "dload_tokeniser"
} ]
],

"model_family": "llama2",
"variant": "7b",

"model_family_information": {
"llama2": {
"name_format": "Llama-2-#{variant}#-chat-hf",
"model_publisher": "meta-llama",
"allowed_variants": ["7b", "13b", "70b"]
},
"llama3": {
"name_format": "Meta-Llama-3-#{variant}#-Instruct",
"model_publisher": "meta-llama",
"allowed_variants": ["8b", "70b"]
},
"llama3_1": {
"name_format": "Llama-3.1-#{variant}#-Instruct",
"model_publisher": "meta-llama",
"allowed_variants": ["8b", "70b", "405b"]
},
"mixtral": {
"name_format": "Mixtral-#{variant}#-Instruct-v0.1",
"model_publisher": "mistralai",
"allowed_variants": ["8x7b", "8x22b"]
}
},

"model_info": [ "^^", "get_model_info" ],

"model_name": [ "^^", "dig", "model_info.model_name"],
"model_publisher": [ "^^", "dig", "model_info.model_publisher" ],

"downloading_tool_query": [ "^^", "substitute", "shell_tool,can_download_url_from_huggingface,hf_token=#{hf_token}#" ],
"uncompressed_split_file_path": [],
"url": [ "AS^IS", "^^", "substitute", "#{model_publisher}#/#{model_name}#"],
"newborn_entry_name": [ "AS^IS", "^^", "substitute", "downloaded_#{model_name}#_#{type}#" ],
"url": [ "^^", "substitute", "#{model_publisher}#/#{model_name}#"],
"newborn_entry_name": [ "^^", "substitute", "downloaded_#{model_name}#_#{type}#" ],

"hf_token": [ "^", "throw", "Must provide a hf_token. You can get this from huggingface" ]
}
12 changes: 12 additions & 0 deletions llm_hf_weights_recipe/docs_axs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Usage

You can use this recipe to download the weights or tokeniser for an LLM on Huggingface.

### Command anatomy
```bash
axs byquery downloaded,
hf_tokeniser, # download a the tokeniser, use `hf_model` to download the model instead
hf_token=$HF_TOKEN, # The token used to access the model, can be obtained from Huggingface
model_family=llama2, # The model family, e.g. llama2 or mixtral
variant=7b # The model variant
```
10 changes: 0 additions & 10 deletions model_llama3_1_recipe/README.md

This file was deleted.

29 changes: 0 additions & 29 deletions model_llama3_1_recipe/data_axs.json

This file was deleted.

7 changes: 0 additions & 7 deletions model_llama3_recipe/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions model_llama3_recipe/data_axs.json

This file was deleted.

0 comments on commit 042dd3a

Please sign in to comment.