Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate vocab support and model conversion #7379

Draft
wants to merge 102 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
dbdf6c2
feat: Add prototype for managing huggingface hub content
teleprint-me May 18, 2024
ba13d64
feat: Add utils for logging and writing when interacting with Hugging…
teleprint-me May 18, 2024
742abeb
refactor: Add log for status and fix url path variable name
teleprint-me May 18, 2024
98cf788
patch: Apply minor fixes for handling headers and writing content
teleprint-me May 18, 2024
4790f76
feat: Add prototype for requesting vocab related files
teleprint-me May 18, 2024
5c8144e
feat: Add download_model method and fix references for clarity to mit…
teleprint-me May 18, 2024
1a286c8
refactor: Clean up variable names and separate concerns when download…
teleprint-me May 18, 2024
3ba01c7
chore: Fix spacing
teleprint-me May 18, 2024
f7515ab
feat: Add tokenizer types, model types, and model repos
teleprint-me May 18, 2024
3022587
refactor: Apply model schema to tokenizer downloads
teleprint-me May 18, 2024
b2ca23c
feat: Add method for generating the checksums and writing the results…
teleprint-me May 18, 2024
5eda2c9
feat: Add pre-tokenizer logging
teleprint-me May 18, 2024
2ef73ee
refactor: Apply SoC for HF requests, vocab, and weights
teleprint-me May 18, 2024
04fb788
chore: Apply isort to package gguf init
teleprint-me May 18, 2024
832b449
feat: Add pre-tokenizer CLI tooling
teleprint-me May 18, 2024
b6f70b8
chore: Fix line spacing
teleprint-me May 18, 2024
006bb60
chore: Fix model path references
teleprint-me May 18, 2024
1a82573
feat: Add example script for automating generating tokenizer model ch…
teleprint-me May 19, 2024
4b3735c
chore: Remove cluttered vocab files
teleprint-me May 19, 2024
0479e96
patch: Add exception handling for non-existent vocab related files
teleprint-me May 19, 2024
bd32266
feat: Add function for generating vocab script and fix CLI opts
teleprint-me May 19, 2024
d02a0f4
feat: Add vocab generation script
teleprint-me May 19, 2024
ce777c8
Merge branch 'master' into auto-model-support
teleprint-me May 19, 2024
da5deeb
fix: Apply fix to verbose help description and generating vocab tests…
teleprint-me May 19, 2024
316b404
patch: Fix CLI option for generating vocab tests
teleprint-me May 19, 2024
5840b6f
refactor: Simplify the get_vocab_base_pre method
teleprint-me May 19, 2024
dcc5d42
fix: Remove dangling if statement
teleprint-me May 19, 2024
c6f2a48
feat: Add prototype for identifying the vocab type
teleprint-me May 20, 2024
89a46fe
feat: Attempt to mirror the llama.cpp API for compatibility
teleprint-me May 20, 2024
a0362ea
patch: Fix nested quotes for dict refs
teleprint-me May 20, 2024
9a2834e
fix: Use __name__ as logger name
teleprint-me May 20, 2024
381dad5
fix: Add missing model architectures
teleprint-me May 20, 2024
6fc4492
chore: Add english pangram to vocab tests
teleprint-me May 20, 2024
a1951e2
refactor: Add proper names for remote model references
teleprint-me May 20, 2024
bdd0286
refactor: Use proper names for referenced member variables
teleprint-me May 20, 2024
18bb36e
chore: Allow the user to config the logger
teleprint-me May 20, 2024
d9ba963
refactor: Restructure tokenizer model metadata
teleprint-me May 20, 2024
2fa2c7a
chore: Move enums and model map to constants
teleprint-me May 20, 2024
5978bb0
chore: Fix and update comments
teleprint-me May 20, 2024
12537fd
chore: Add tokenizer constants for model metadata
teleprint-me May 21, 2024
aed0573
proto: Add experimental vocab pre-tokenizer regular expressions
teleprint-me May 21, 2024
a35b767
Merge branch 'master' into auto-model-support
teleprint-me May 21, 2024
6296206
chore: Apply deduped token type references
teleprint-me May 21, 2024
a3bdac0
chore: Remove unused enum import reference
teleprint-me May 21, 2024
fb32f50
feat: Add hf model mapping descriptors for each repo
teleprint-me May 21, 2024
4768650
chore: Add formatting, set common vocab files, apply pattern to model…
teleprint-me May 21, 2024
2fe28ad
chore: Rename from repo to model repo and reorder for improved readab…
teleprint-me May 21, 2024
83b9fcd
refactor: Rename constants to reduce confusion between references
teleprint-me May 21, 2024
b2aac68
docs: Fix comment
teleprint-me May 21, 2024
34e14ae
refactor: Add experimental model mappings
teleprint-me May 21, 2024
0b43e14
refactor: Add experimental mapping for BPE pre-tokenizers
teleprint-me May 22, 2024
12285b5
chore: Map model file and vocab types
teleprint-me May 22, 2024
1957ca4
refactor: Simplify BPE pre-tokenizer mapping
teleprint-me May 22, 2024
cd00be8
chore: Add model metadata
teleprint-me May 22, 2024
78d7828
chore: Add prototyped CLI options
teleprint-me May 22, 2024
9814b7f
feat: Add custom huggingface hub api
teleprint-me May 23, 2024
9ba6b92
chore: Add required vocabulary constants
teleprint-me May 23, 2024
0ccf579
refactor: Apply consistent naming conventions
teleprint-me May 23, 2024
c92c6ad
feat: Add CLI tool for fetching vocab files
teleprint-me May 24, 2024
1749209
refactor: Simplify huggingface hub api implementation
teleprint-me May 24, 2024
f62080a
refactor: Simplify huggingface hub vocab request
teleprint-me May 24, 2024
ea4fc10
refactor: Apply fixes to required arguments and fixes to options
teleprint-me May 24, 2024
b4b553f
chore: Apply ruff formatting for readability
teleprint-me May 24, 2024
77bc739
refactor: Add tokenizer path, add methods for extracting vocab metada…
teleprint-me May 24, 2024
c91dcdf
refactor: Add fixes for logging
teleprint-me May 24, 2024
e62e09b
refactor: Apply fix for file path references
teleprint-me May 24, 2024
6c9ac0f
refactor: Add a custom tokenizer component and fix vocab request class
teleprint-me May 24, 2024
6409694
refactor: Simplify the huggingface hub api to enable flexible model r…
teleprint-me May 24, 2024
6da2bd6
patch: Apply fix for paths and logging
teleprint-me May 25, 2024
168297f
refactor: Add remote repository listings to the bas HFHub class
teleprint-me May 25, 2024
99275a1
refactor: Simplify API and merge HFModel into HFHub
teleprint-me May 25, 2024
4438d05
refactor: Abstract file and logger management to streamline api inter…
teleprint-me May 25, 2024
fda2319
refactor: Streamline method signatures and clarify method names relat…
teleprint-me May 25, 2024
2ffe6b8
Refactor HFubModel and HFHubTokenizer to fix reference issues
teleprint-me May 25, 2024
63c3410
refactor: Add support for model file types
teleprint-me May 25, 2024
6c1b011
refactor: Apply huggingface_hub api to CLI
teleprint-me May 25, 2024
e9759de
docs: Add revisions to hub-vocab.py module level docstring
teleprint-me May 25, 2024
f30bd63
refactor: Add function for building and parsing CLI arguments
teleprint-me May 25, 2024
da72554
feat: Add static methods for resolving model types and model extensions
teleprint-me May 25, 2024
fcd20ab
chore: Add comments for each file extension type
teleprint-me May 25, 2024
e4275bc
feat: Add example script for downloading models
teleprint-me May 25, 2024
b3a5429
Merge branch 'huggingface-hub-api' into auto-model-support
teleprint-me May 26, 2024
36bea17
Merge branch 'master' into auto-model-support
teleprint-me May 26, 2024
7f48eb9
feat: Add experimental model registry for known models and their rela…
teleprint-me May 27, 2024
b1c922f
feat: Add a proto sketch for handling mode vocab metadata
teleprint-me May 27, 2024
0732bd9
feat: Ignore pre-existing model files
teleprint-me May 27, 2024
2153949
feat: Add prototype for bootstrapping registry
teleprint-me May 27, 2024
0a478c0
chore: Add pre tokenizers and include enum mappings
teleprint-me May 27, 2024
9dbc957
refactor: Simplify tokenizers implementation
teleprint-me May 28, 2024
aa28cfe
chore: Fix import path, token comparisons, and update token type refe…
teleprint-me May 28, 2024
f1d067e
refactor: Simplify huggingface hub api and update to reflect changes …
teleprint-me May 28, 2024
5c92809
refactor: Apply updates to example script for generating the registry
teleprint-me May 28, 2024
6a725cf
Merge branch 'master' into auto-model-support
teleprint-me May 28, 2024
de0f0d0
Merge branch 'master' into auto-model-support
teleprint-me May 29, 2024
c2e4897
Merge branch 'master' into auto-model-support
teleprint-me May 31, 2024
47ef615
refactor: Add prototyped bridge interface for tokenizers and llama.cpp
teleprint-me Jun 1, 2024
c447010
refactor: Add prototyped bridge interface for transformers and tokeni…
teleprint-me Jun 1, 2024
647d252
patch: Apply fix for backward compat for source repo
teleprint-me Jun 1, 2024
250bddf
Merge branch 'master' into auto-model-support
teleprint-me Jun 2, 2024
e2b7608
chore: Add ignore rule for generated server themes
teleprint-me Jun 2, 2024
ce8524a
Merge branch 'ignore-gen-themes' into auto-model-support
teleprint-me Jun 2, 2024
5836d6c
refactor: Clean up constants and simplify the custom hf hub api
teleprint-me Jun 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ examples/jeopardy/results.txt
examples/server/*.html.hpp
examples/server/*.js.hpp
examples/server/*.mjs.hpp
examples/server/*.css.hpp

poetry.lock
poetry.toml
Expand Down
228 changes: 88 additions & 140 deletions convert-hf-to-gguf.py

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions generate-vocab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

python3 convert-hf-to-gguf.py models/meta-llama/Llama-2-7b-hf --outfile models/meta-llama/Llama-2-7b-hf/ggml-vocab-llama-2-7b-hf.gguf --vocab-only
python3 convert-hf-to-gguf.py models/meta-llama/Meta-Llama-3-8B --outfile models/meta-llama/Meta-Llama-3-8B/ggml-vocab-meta-llama-3-8b.gguf --vocab-only
python3 convert-hf-to-gguf.py models/microsoft/Phi-3-mini-4k-instruct --outfile models/microsoft/Phi-3-mini-4k-instruct/ggml-vocab-phi-3-mini-4k-instruct.gguf --vocab-only
python3 convert-hf-to-gguf.py models/deepseek-ai/deepseek-llm-7b-base --outfile models/deepseek-ai/deepseek-llm-7b-base/ggml-vocab-deepseek-llm-7b-base.gguf --vocab-only
python3 convert-hf-to-gguf.py models/deepseek-ai/deepseek-coder-6.7b-base --outfile models/deepseek-ai/deepseek-coder-6.7b-base/ggml-vocab-deepseek-coder-6.gguf --vocab-only
python3 convert-hf-to-gguf.py models/tiiuae/falcon-7b --outfile models/tiiuae/falcon-7b/ggml-vocab-falcon-7b.gguf --vocab-only
python3 convert-hf-to-gguf.py models/BAAI/bge-small-en-v1.5 --outfile models/BAAI/bge-small-en-v1.5/ggml-vocab-bge-small-en-v1.gguf --vocab-only
python3 convert-hf-to-gguf.py models/mosaicml/mpt-7b --outfile models/mosaicml/mpt-7b/ggml-vocab-mpt-7b.gguf --vocab-only
python3 convert-hf-to-gguf.py models/bigcode/starcoder2-3b --outfile models/bigcode/starcoder2-3b/ggml-vocab-starcoder2-3b.gguf --vocab-only
python3 convert-hf-to-gguf.py models/openai-community/gpt2 --outfile models/openai-community/gpt2/ggml-vocab-gpt2.gguf --vocab-only
python3 convert-hf-to-gguf.py models/smallcloudai/Refact-1_6-base --outfile models/smallcloudai/Refact-1_6-base/ggml-vocab-refact-1_6-base.gguf --vocab-only
python3 convert-hf-to-gguf.py models/CohereForAI/c4ai-command-r-v01 --outfile models/CohereForAI/c4ai-command-r-v01/ggml-vocab-c4ai-command-r-v01.gguf --vocab-only
python3 convert-hf-to-gguf.py models/Qwen/Qwen1.5-7B --outfile models/Qwen/Qwen1.5-7B/ggml-vocab-qwen1.gguf --vocab-only
python3 convert-hf-to-gguf.py models/allenai/OLMo-1.7-7B-hf --outfile models/allenai/OLMo-1.7-7B-hf/ggml-vocab-olmo-1.gguf --vocab-only
# python3 convert-hf-to-gguf.py models/databricks/dbrx-base --outfile models/databricks/dbrx-base/ggml-vocab-dbrx-base.gguf --vocab-only
python3 convert-hf-to-gguf.py models/jinaai/jina-embeddings-v2-base-en --outfile models/jinaai/jina-embeddings-v2-base-en/ggml-vocab-jina-embeddings-v2-base-en.gguf --vocab-only
python3 convert-hf-to-gguf.py models/jinaai/jina-embeddings-v2-base-es --outfile models/jinaai/jina-embeddings-v2-base-es/ggml-vocab-jina-embeddings-v2-base-es.gguf --vocab-only
python3 convert-hf-to-gguf.py models/jinaai/jina-embeddings-v2-base-de --outfile models/jinaai/jina-embeddings-v2-base-de/ggml-vocab-jina-embeddings-v2-base-de.gguf --vocab-only
python3 convert-hf-to-gguf.py models/microsoft/phi-1 --outfile models/microsoft/phi-1/ggml-vocab-phi-1.gguf --vocab-only
python3 convert-hf-to-gguf.py models/stabilityai/stablelm-2-zephyr-1_6b --outfile models/stabilityai/stablelm-2-zephyr-1_6b/ggml-vocab-stablelm-2-zephyr-1_6b.gguf --vocab-only
python3 convert-hf-to-gguf.py models/mistralai/Mistral-7B-Instruct-v0.2 --outfile models/mistralai/Mistral-7B-Instruct-v0.2/ggml-vocab-mistral-7b-instruct-v0.gguf --vocab-only
python3 convert-hf-to-gguf.py models/mistralai/Mixtral-8x7B-Instruct-v0.1 --outfile models/mistralai/Mixtral-8x7B-Instruct-v0.1/ggml-vocab-mixtral-8x7b-instruct-v0.gguf --vocab-only
3 changes: 2 additions & 1 deletion gguf-py/gguf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .constants import *
from .lazy import *
from .gguf_reader import *
from .gguf_writer import *
from .huggingface_hub import *
from .lazy import *
from .quants import *
from .tensor_mapping import *
from .vocab import *
Loading
Loading