-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from krai/better_llm_downloading
Better llm model/tokeniser downloading
- Loading branch information
Showing
8 changed files
with
64 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.