From eac2e83f9f26f15f28e09236a30584b1503d95f5 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 12 May 2024 19:51:55 -0400
Subject: [PATCH 01/19] gguf: Add example script for extracting chat template
---
gguf-py/scripts/gguf-template.py | 103 +++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
create mode 100644 gguf-py/scripts/gguf-template.py
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
new file mode 100644
index 0000000000000..301b416283452
--- /dev/null
+++ b/gguf-py/scripts/gguf-template.py
@@ -0,0 +1,103 @@
+"""
+gguf_chat_template.py - example file to extract the chat template from the models metadata
+"""
+
+from __future__ import annotations
+
+import argparse
+import logging
+import os
+import sys
+from pathlib import Path
+
+import jinja2
+
+# Necessary to load the local gguf package
+if "NO_LOCAL_GGUF" not in os.environ and (Path(__file__).parent.parent.parent / 'gguf-py').exists():
+ sys.path.insert(0, str(Path(__file__).parent.parent))
+
+from gguf.constants import Keys
+from gguf.gguf_reader import GGUFReader # noqa: E402
+
+# Configure logging
+logging.basicConfig(level=logging.INFO)
+logger = logging.getLogger("gguf-chat-template")
+
+
+def get_chat_template(model_file: str) -> str:
+ reader = GGUFReader(model_file)
+
+ # Available keys
+ logger.info("Detected model metadata!")
+ logger.info("Outputting available model fields:")
+ for key in reader.fields.keys():
+ logger.info(key)
+
+ # Access the 'chat_template' field directly using its key
+ chat_template_field = reader.fields.get(Keys.Tokenizer.CHAT_TEMPLATE)
+
+ if chat_template_field:
+ # Extract the chat template string from the field
+ chat_template_memmap = chat_template_field.parts[-1]
+ chat_template_string = chat_template_memmap.tobytes().decode("utf-8")
+ return chat_template_string
+ else:
+ logger.error("Chat template field not found in model metadata.")
+ return ""
+
+
+def display_chat_template(chat_template: str, format_template: bool = False):
+ """
+ Display the chat template to standard output, optionally formatting it using Jinja2.
+
+ Args:
+ chat_template (str): The extracted chat template.
+ format_template (bool, optional): Whether to format the template using Jinja2. Defaults to False.
+ """
+ logger.info(f"Format Template: {format_template}")
+
+ if format_template:
+ # Render the formatted template using Jinja2 with a context that includes 'bos_token' and 'eos_token'
+ env = jinja2.Environment(
+ loader=jinja2.BaseLoader(),
+ trim_blocks=True,
+ lstrip_blocks=True,
+ )
+ logger.info(chat_template)
+ template = env.from_string(chat_template)
+ formatted_template = template.render(
+ messages=[
+ {"role": "system", "content": "I am a helpful assistant."},
+ {"role": "user", "content": "Hello!"},
+ ],
+ bos_token="[BOS]",
+ eos_token="[EOS]",
+ )
+ print(formatted_template)
+ else:
+ # Display the raw template
+ print(chat_template)
+
+
+# Example usage:
+def main() -> None:
+ parser = argparse.ArgumentParser(
+ description="Extract chat template from a GGUF model file"
+ )
+ parser.add_argument("model_file", type=str, help="Path to the GGUF model file")
+ parser.add_argument(
+ "--format",
+ action="store_true",
+ help="Format the chat template using Jinja2",
+ )
+
+ args = parser.parse_args()
+
+ model_file = args.model_file
+ chat_template = get_chat_template(model_file)
+
+ display_chat_template(chat_template, format_template=args.format)
+
+
+if __name__ == "__main__":
+ main()
From bf5154f9bc717118b20738982902a3e8f738896c Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 12 May 2024 20:07:30 -0400
Subject: [PATCH 02/19] docs: Fix filename in docstring and remove return type
from main
---
gguf-py/scripts/gguf-template.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index 301b416283452..cfa8bbfb3633c 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -1,5 +1,5 @@
"""
-gguf_chat_template.py - example file to extract the chat template from the models metadata
+gguf-template.py - example file to extract the chat template from the models metadata
"""
from __future__ import annotations
@@ -80,7 +80,7 @@ def display_chat_template(chat_template: str, format_template: bool = False):
# Example usage:
-def main() -> None:
+def main():
parser = argparse.ArgumentParser(
description="Extract chat template from a GGUF model file"
)
From 4a018e706f0be37c0d4aa6a44a7dd43d3811eca0 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 12 May 2024 20:08:37 -0400
Subject: [PATCH 03/19] feat: Add assistant turn
---
gguf-py/scripts/gguf-template.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index cfa8bbfb3633c..dff9023ca320c 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -69,6 +69,7 @@ def display_chat_template(chat_template: str, format_template: bool = False):
messages=[
{"role": "system", "content": "I am a helpful assistant."},
{"role": "user", "content": "Hello!"},
+ {"role": "assistant", "content": "Hello! How may I assist you today?"},
],
bos_token="[BOS]",
eos_token="[EOS]",
From 8b9ed888bca7e5cd44880306b1041e2d92fab028 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 12 May 2024 20:17:35 -0400
Subject: [PATCH 04/19] patch: Handle how templates are rendered if no system
prompt is allowed
---
gguf-py/scripts/gguf-template.py | 37 +++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index dff9023ca320c..1f5408965f56d 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -59,21 +59,32 @@ def display_chat_template(chat_template: str, format_template: bool = False):
if format_template:
# Render the formatted template using Jinja2 with a context that includes 'bos_token' and 'eos_token'
env = jinja2.Environment(
- loader=jinja2.BaseLoader(),
- trim_blocks=True,
- lstrip_blocks=True,
+ loader=jinja2.BaseLoader(), trim_blocks=True, lstrip_blocks=True
)
- logger.info(chat_template)
template = env.from_string(chat_template)
- formatted_template = template.render(
- messages=[
- {"role": "system", "content": "I am a helpful assistant."},
- {"role": "user", "content": "Hello!"},
- {"role": "assistant", "content": "Hello! How may I assist you today?"},
- ],
- bos_token="[BOS]",
- eos_token="[EOS]",
- )
+
+ messages = [
+ {"role": "system", "content": "I am a helpful assistant."},
+ {"role": "user", "content": "Hello!"},
+ {"role": "assistant", "content": "Hello! How may I assist you today?"},
+ ]
+ bos_token = ""
+ eos_token = ""
+
+ try:
+ formatted_template = template.render(
+ messages=messages,
+ bos_token=bos_token,
+ eos_token=eos_token,
+ )
+ except jinja2.exceptions.UndefinedError:
+ # system message is incompatible with set format
+ formatted_template = template.render(
+ messages=messages[1:],
+ bos_token=bos_token,
+ eos_token=eos_token,
+ )
+
print(formatted_template)
else:
# Display the raw template
From 668c7ee6c51506b2798bed8b5beb074670c407be Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 12 May 2024 20:37:27 -0400
Subject: [PATCH 05/19] refactor: Use render template instead of format
---
gguf-py/scripts/gguf-template.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index 1f5408965f56d..b29c27c745c40 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -46,17 +46,17 @@ def get_chat_template(model_file: str) -> str:
return ""
-def display_chat_template(chat_template: str, format_template: bool = False):
+def display_chat_template(chat_template: str, render_template: bool = False):
"""
Display the chat template to standard output, optionally formatting it using Jinja2.
Args:
chat_template (str): The extracted chat template.
- format_template (bool, optional): Whether to format the template using Jinja2. Defaults to False.
+ render_template (bool, optional): Whether to format the template using Jinja2. Defaults to False.
"""
- logger.info(f"Format Template: {format_template}")
+ logger.info(f"Format Template: {render_template}")
- if format_template:
+ if render_template:
# Render the formatted template using Jinja2 with a context that includes 'bos_token' and 'eos_token'
env = jinja2.Environment(
loader=jinja2.BaseLoader(), trim_blocks=True, lstrip_blocks=True
@@ -98,9 +98,10 @@ def main():
)
parser.add_argument("model_file", type=str, help="Path to the GGUF model file")
parser.add_argument(
- "--format",
+ "-r",
+ "--render-template",
action="store_true",
- help="Format the chat template using Jinja2",
+ help="Render the chat template using Jinja2",
)
args = parser.parse_args()
@@ -108,7 +109,7 @@ def main():
model_file = args.model_file
chat_template = get_chat_template(model_file)
- display_chat_template(chat_template, format_template=args.format)
+ display_chat_template(chat_template, render_template=args.render_template)
if __name__ == "__main__":
From fa0b0b10ccd0bc678d01b1c0aa0a33681ece9595 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 12 May 2024 20:39:55 -0400
Subject: [PATCH 06/19] feat: Allow toggling verbosity
---
gguf-py/scripts/gguf-template.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index b29c27c745c40..d3757b4f39004 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -24,14 +24,15 @@
logger = logging.getLogger("gguf-chat-template")
-def get_chat_template(model_file: str) -> str:
+def get_chat_template(model_file: str, verbose: bool = False) -> str:
reader = GGUFReader(model_file)
# Available keys
logger.info("Detected model metadata!")
- logger.info("Outputting available model fields:")
- for key in reader.fields.keys():
- logger.info(key)
+ if verbose:
+ logger.info("Outputting available model fields:")
+ for key in reader.fields.keys():
+ logger.info(key)
# Access the 'chat_template' field directly using its key
chat_template_field = reader.fields.get(Keys.Tokenizer.CHAT_TEMPLATE)
@@ -103,12 +104,16 @@ def main():
action="store_true",
help="Render the chat template using Jinja2",
)
-
+ parser.add_argument(
+ "-v",
+ "--verbose",
+ action="store_true",
+ help="Output model keys",
+ )
args = parser.parse_args()
model_file = args.model_file
- chat_template = get_chat_template(model_file)
-
+ chat_template = get_chat_template(model_file, args.verbose)
display_chat_template(chat_template, render_template=args.render_template)
From 6be3576e014e82b2f33f2e900e5bf03d808a36d7 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 12 May 2024 20:48:29 -0400
Subject: [PATCH 07/19] feat: Add sane defaults and options for setting special
tokens
---
gguf-py/scripts/gguf-template.py | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index d3757b4f39004..e5f80c69d42a8 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -47,7 +47,9 @@ def get_chat_template(model_file: str, verbose: bool = False) -> str:
return ""
-def display_chat_template(chat_template: str, render_template: bool = False):
+def display_chat_template(
+ chat_template: str, bos_token: str, eos_token: str, render_template: bool = False
+):
"""
Display the chat template to standard output, optionally formatting it using Jinja2.
@@ -68,9 +70,9 @@ def display_chat_template(chat_template: str, render_template: bool = False):
{"role": "system", "content": "I am a helpful assistant."},
{"role": "user", "content": "Hello!"},
{"role": "assistant", "content": "Hello! How may I assist you today?"},
+ {"role": "user", "content": "Can you tell me what pickled mayonnaise is?"},
+ {"role": "assistant", "content": "Certainly! What would you like to know about it?"},
]
- bos_token = ""
- eos_token = ""
try:
formatted_template = template.render(
@@ -104,6 +106,18 @@ def main():
action="store_true",
help="Render the chat template using Jinja2",
)
+ parser.add_argument(
+ "-b",
+ "--bos",
+ default="",
+ help="Set a bos special token. Default is ''.",
+ )
+ parser.add_argument(
+ "-e",
+ "--eos",
+ default="",
+ help="Set a eos special token. Default is ''.",
+ )
parser.add_argument(
"-v",
"--verbose",
@@ -114,7 +128,9 @@ def main():
model_file = args.model_file
chat_template = get_chat_template(model_file, args.verbose)
- display_chat_template(chat_template, render_template=args.render_template)
+ display_chat_template(
+ chat_template, args.bos, args.eos, render_template=args.render_template
+ )
if __name__ == "__main__":
From 214e9e6f0b67d288e0d40125c3c551252d7614e4 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 12 May 2024 21:07:05 -0400
Subject: [PATCH 08/19] refactor: Add logging debug and clean up logger
implementation
---
gguf-py/scripts/gguf-template.py | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index e5f80c69d42a8..aa042db77d542 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -20,19 +20,17 @@
from gguf.gguf_reader import GGUFReader # noqa: E402
# Configure logging
-logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("gguf-chat-template")
-def get_chat_template(model_file: str, verbose: bool = False) -> str:
+def get_chat_template(model_file: str) -> str:
reader = GGUFReader(model_file)
# Available keys
- logger.info("Detected model metadata!")
- if verbose:
- logger.info("Outputting available model fields:")
- for key in reader.fields.keys():
- logger.info(key)
+ logger.debug("Detected model metadata!")
+ logger.debug("Outputting available model fields:")
+ for key in reader.fields.keys():
+ logger.debug(key)
# Access the 'chat_template' field directly using its key
chat_template_field = reader.fields.get(Keys.Tokenizer.CHAT_TEMPLATE)
@@ -57,7 +55,7 @@ def display_chat_template(
chat_template (str): The extracted chat template.
render_template (bool, optional): Whether to format the template using Jinja2. Defaults to False.
"""
- logger.info(f"Format Template: {render_template}")
+ logger.debug(f"Render Template: {render_template}")
if render_template:
# Render the formatted template using Jinja2 with a context that includes 'bos_token' and 'eos_token'
@@ -126,8 +124,12 @@ def main():
)
args = parser.parse_args()
- model_file = args.model_file
- chat_template = get_chat_template(model_file, args.verbose)
+ if args.verbose:
+ logging.basicConfig(level=logging.DEBUG)
+ else:
+ logging.basicConfig(level=logging.INFO)
+
+ chat_template = get_chat_template(args.model_file)
display_chat_template(
chat_template, args.bos, args.eos, render_template=args.render_template
)
From f8bb2239249937bb58eeb99d130959dff719e6b7 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 12 May 2024 21:17:04 -0400
Subject: [PATCH 09/19] refactor: Remove rename from display to render and
return result instead of printing
---
gguf-py/scripts/gguf-template.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index aa042db77d542..764a76b8fe444 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -45,9 +45,9 @@ def get_chat_template(model_file: str) -> str:
return ""
-def display_chat_template(
+def render_chat_template(
chat_template: str, bos_token: str, eos_token: str, render_template: bool = False
-):
+) -> str:
"""
Display the chat template to standard output, optionally formatting it using Jinja2.
@@ -86,10 +86,10 @@ def display_chat_template(
eos_token=eos_token,
)
- print(formatted_template)
+ return formatted_template
else:
# Display the raw template
- print(chat_template)
+ return chat_template
# Example usage:
@@ -130,9 +130,10 @@ def main():
logging.basicConfig(level=logging.INFO)
chat_template = get_chat_template(args.model_file)
- display_chat_template(
+ rendered_template = render_chat_template(
chat_template, args.bos, args.eos, render_template=args.render_template
)
+ print(rendered_template)
if __name__ == "__main__":
From da96fdd15f8aa3c0f08b23ae1109d0c775272f97 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Mon, 13 May 2024 13:10:44 -0400
Subject: [PATCH 10/19] patch: Apply patch for advisories/GHSA-56xg-wfcc-g829
Signed-off-by: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
---
gguf-py/scripts/gguf-template.py | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index 764a76b8fe444..78d9524752a53 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -11,6 +11,7 @@
from pathlib import Path
import jinja2
+import jinja2.sandbox
# Necessary to load the local gguf package
if "NO_LOCAL_GGUF" not in os.environ and (Path(__file__).parent.parent.parent / 'gguf-py').exists():
@@ -46,7 +47,10 @@ def get_chat_template(model_file: str) -> str:
def render_chat_template(
- chat_template: str, bos_token: str, eos_token: str, render_template: bool = False
+ chat_template: str,
+ bos_token: str,
+ eos_token: str,
+ render_template: bool = False,
) -> str:
"""
Display the chat template to standard output, optionally formatting it using Jinja2.
@@ -59,8 +63,8 @@ def render_chat_template(
if render_template:
# Render the formatted template using Jinja2 with a context that includes 'bos_token' and 'eos_token'
- env = jinja2.Environment(
- loader=jinja2.BaseLoader(), trim_blocks=True, lstrip_blocks=True
+ env = jinja2.sandbox.ImmutableSandboxedEnvironment(
+ trim_blocks=True, lstrip_blocks=True
)
template = env.from_string(chat_template)
@@ -131,9 +135,12 @@ def main():
chat_template = get_chat_template(args.model_file)
rendered_template = render_chat_template(
- chat_template, args.bos, args.eos, render_template=args.render_template
+ chat_template,
+ args.bos,
+ args.eos,
+ render_template=args.render_template,
)
- print(rendered_template)
+ print(rendered_template) # noqa: NP100
if __name__ == "__main__":
From cfe659d90a589d504c82786e029298312aef0781 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Mon, 13 May 2024 13:12:38 -0400
Subject: [PATCH 11/19] feat: Add option for adding generation prompt
Signed-off-by: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
---
gguf-py/scripts/gguf-template.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index 78d9524752a53..ef2b781484e21 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -50,6 +50,7 @@ def render_chat_template(
chat_template: str,
bos_token: str,
eos_token: str,
+ add_generation_prompt: bool = False,
render_template: bool = False,
) -> str:
"""
@@ -60,6 +61,7 @@ def render_chat_template(
render_template (bool, optional): Whether to format the template using Jinja2. Defaults to False.
"""
logger.debug(f"Render Template: {render_template}")
+ logger.debug(f"Add Generation Prompt: {add_generation_prompt}")
if render_template:
# Render the formatted template using Jinja2 with a context that includes 'bos_token' and 'eos_token'
@@ -81,6 +83,7 @@ def render_chat_template(
messages=messages,
bos_token=bos_token,
eos_token=eos_token,
+ add_generation_prompt=add_generation_prompt,
)
except jinja2.exceptions.UndefinedError:
# system message is incompatible with set format
@@ -88,6 +91,7 @@ def render_chat_template(
messages=messages[1:],
bos_token=bos_token,
eos_token=eos_token,
+ add_generation_prompt=add_generation_prompt,
)
return formatted_template
@@ -120,6 +124,12 @@ def main():
default="",
help="Set a eos special token. Default is ''.",
)
+ parser.add_argument(
+ "-g",
+ "--agp",
+ action="store_true",
+ help="Add generation prompt. Default is True.",
+ )
parser.add_argument(
"-v",
"--verbose",
@@ -138,6 +148,7 @@ def main():
chat_template,
args.bos,
args.eos,
+ add_generation_prompt=args.agp,
render_template=args.render_template,
)
print(rendered_template) # noqa: NP100
From b4b6f1fa00373146426de6ad634b7c7723fbeb8e Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Wed, 15 May 2024 12:54:55 -0400
Subject: [PATCH 12/19] fix: End messages with a user role due to jinja2
conditional checks
Signed-off-by: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
---
gguf-py/scripts/gguf-template.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index ef2b781484e21..27b6e9f3c7861 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -76,6 +76,7 @@ def render_chat_template(
{"role": "assistant", "content": "Hello! How may I assist you today?"},
{"role": "user", "content": "Can you tell me what pickled mayonnaise is?"},
{"role": "assistant", "content": "Certainly! What would you like to know about it?"},
+ {"role": "user", "content": "Is it just regular mayonnaise with vinegar or something else?"},
]
try:
From 2185e5cf14cdc7e588587d4aa190a152868d4823 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Wed, 15 May 2024 12:58:24 -0400
Subject: [PATCH 13/19] docs: Update and fix CLI help descriptions
Signed-off-by: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
---
gguf-py/scripts/gguf-template.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py
index 27b6e9f3c7861..43f3bca9e5567 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf-template.py
@@ -111,7 +111,7 @@ def main():
"-r",
"--render-template",
action="store_true",
- help="Render the chat template using Jinja2",
+ help="Render the chat template using Jinja2. Default is False.",
)
parser.add_argument(
"-b",
@@ -129,13 +129,13 @@ def main():
"-g",
"--agp",
action="store_true",
- help="Add generation prompt. Default is True.",
+ help="Add generation prompt. Default is False.",
)
parser.add_argument(
"-v",
"--verbose",
action="store_true",
- help="Output model keys",
+ help="Output model keys. Default is False.",
)
args = parser.parse_args()
From 4204cab3908c7cf712c6a359e00d17761f0586e2 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Sun, 14 Jul 2024 00:34:07 -0400
Subject: [PATCH 14/19] chore : Apply snake case as described in #8305
Signed-off-by: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
---
gguf-py/scripts/{gguf-template.py => gguf_template.py} | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename gguf-py/scripts/{gguf-template.py => gguf_template.py} (98%)
diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf_template.py
similarity index 98%
rename from gguf-py/scripts/gguf-template.py
rename to gguf-py/scripts/gguf_template.py
index 43f3bca9e5567..c66224870d83f 100644
--- a/gguf-py/scripts/gguf-template.py
+++ b/gguf-py/scripts/gguf_template.py
@@ -1,5 +1,5 @@
"""
-gguf-template.py - example file to extract the chat template from the models metadata
+gguf_template.py - example file to extract the chat template from the models metadata
"""
from __future__ import annotations
From b7528fdf89d4636f5c44b89e7fd1907d31e42abe Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Mon, 15 Jul 2024 13:56:54 -0400
Subject: [PATCH 15/19] chore : Add jinja2 as dev dependency in pyproject.toml
and explicit dependency in requirements.txt
---
gguf-py/pyproject.toml | 1 +
requirements/requirements-convert_legacy_llama.txt | 1 +
2 files changed, 2 insertions(+)
diff --git a/gguf-py/pyproject.toml b/gguf-py/pyproject.toml
index 62129126bdddc..e1f175e699973 100644
--- a/gguf-py/pyproject.toml
+++ b/gguf-py/pyproject.toml
@@ -25,6 +25,7 @@ tqdm = ">=4.27"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
+jinja2 = ">=3.1.0"
[build-system]
requires = ["poetry-core>=1.0.0"]
diff --git a/requirements/requirements-convert_legacy_llama.txt b/requirements/requirements-convert_legacy_llama.txt
index 1d07b09522f61..4950705aa24b4 100644
--- a/requirements/requirements-convert_legacy_llama.txt
+++ b/requirements/requirements-convert_legacy_llama.txt
@@ -1,5 +1,6 @@
numpy~=1.26.4
sentencepiece~=0.2.0
transformers>=4.40.1,<5.0.0
+jinja2>=3.1.0
gguf>=0.1.0
protobuf>=4.21.0,<5.0.0
From 0cb404cc13d501ad11beed20b20f68e34b6a43e3 Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Mon, 15 Jul 2024 13:57:46 -0400
Subject: [PATCH 16/19] feat : Add shebang and executable bit to enable script
execution
---
gguf-py/scripts/gguf_template.py | 1 +
1 file changed, 1 insertion(+)
mode change 100644 => 100755 gguf-py/scripts/gguf_template.py
diff --git a/gguf-py/scripts/gguf_template.py b/gguf-py/scripts/gguf_template.py
old mode 100644
new mode 100755
index c66224870d83f..6bb1c10213c84
--- a/gguf-py/scripts/gguf_template.py
+++ b/gguf-py/scripts/gguf_template.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
"""
gguf_template.py - example file to extract the chat template from the models metadata
"""
From 0de43fcc00f37e300a3dc168f0b8bfde06ea9aac Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Fri, 19 Jul 2024 14:05:21 -0400
Subject: [PATCH 17/19] chore : Set sentencepiece to 0.2.0 to match
requirements.txt
Signed-off-by: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
---
poetry.lock | 105 ++++++++++++++++++++++++++-----------------------
pyproject.toml | 2 +-
2 files changed, 57 insertions(+), 50 deletions(-)
diff --git a/poetry.lock b/poetry.lock
index eb6baa6c749c0..562e72a00bcd2 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
+# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
[[package]]
name = "atomicwrites"
@@ -543,7 +543,6 @@ files = [
{file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"},
- {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"},
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"},
{file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"},
{file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},
@@ -835,56 +834,64 @@ torch = ["safetensors[numpy]", "torch (>=1.10)"]
[[package]]
name = "sentencepiece"
-version = "0.1.99"
+version = "0.2.0"
description = "SentencePiece python wrapper"
optional = false
python-versions = "*"
files = [
- {file = "sentencepiece-0.1.99-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0eb528e70571b7c02723e5804322469b82fe7ea418c96051d0286c0fa028db73"},
- {file = "sentencepiece-0.1.99-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:77d7fafb2c4e4659cbdf303929503f37a26eabc4ff31d3a79bf1c5a1b338caa7"},
- {file = "sentencepiece-0.1.99-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:be9cf5b9e404c245aeb3d3723c737ba7a8f5d4ba262ef233a431fa6c45f732a0"},
- {file = "sentencepiece-0.1.99-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:baed1a26464998f9710d20e52607c29ffd4293e7c71c6a1f83f51ad0911ec12c"},
- {file = "sentencepiece-0.1.99-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9832f08bb372d4c8b567612f8eab9e36e268dff645f1c28f9f8e851be705f6d1"},
- {file = "sentencepiece-0.1.99-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:019e7535108e309dae2b253a75834fc3128240aa87c00eb80732078cdc182588"},
- {file = "sentencepiece-0.1.99-cp310-cp310-win32.whl", hash = "sha256:fa16a830416bb823fa2a52cbdd474d1f7f3bba527fd2304fb4b140dad31bb9bc"},
- {file = "sentencepiece-0.1.99-cp310-cp310-win_amd64.whl", hash = "sha256:14b0eccb7b641d4591c3e12ae44cab537d68352e4d3b6424944f0c447d2348d5"},
- {file = "sentencepiece-0.1.99-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6d3c56f24183a1e8bd61043ff2c58dfecdc68a5dd8955dc13bab83afd5f76b81"},
- {file = "sentencepiece-0.1.99-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ed6ea1819fd612c989999e44a51bf556d0ef6abfb553080b9be3d347e18bcfb7"},
- {file = "sentencepiece-0.1.99-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a2a0260cd1fb7bd8b4d4f39dc2444a8d5fd4e0a0c4d5c899810ef1abf99b2d45"},
- {file = "sentencepiece-0.1.99-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8a1abff4d1ff81c77cac3cc6fefa34fa4b8b371e5ee51cb7e8d1ebc996d05983"},
- {file = "sentencepiece-0.1.99-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:004e6a621d4bc88978eecb6ea7959264239a17b70f2cbc348033d8195c9808ec"},
- {file = "sentencepiece-0.1.99-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db361e03342c41680afae5807590bc88aa0e17cfd1a42696a160e4005fcda03b"},
- {file = "sentencepiece-0.1.99-cp311-cp311-win32.whl", hash = "sha256:2d95e19168875b70df62916eb55428a0cbcb834ac51d5a7e664eda74def9e1e0"},
- {file = "sentencepiece-0.1.99-cp311-cp311-win_amd64.whl", hash = "sha256:f90d73a6f81248a909f55d8e6ef56fec32d559e1e9af045f0b0322637cb8e5c7"},
- {file = "sentencepiece-0.1.99-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:62e24c81e74bd87a6e0d63c51beb6527e4c0add67e1a17bac18bcd2076afcfeb"},
- {file = "sentencepiece-0.1.99-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:57efcc2d51caff20d9573567d9fd3f854d9efe613ed58a439c78c9f93101384a"},
- {file = "sentencepiece-0.1.99-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6a904c46197993bd1e95b93a6e373dca2f170379d64441041e2e628ad4afb16f"},
- {file = "sentencepiece-0.1.99-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d89adf59854741c0d465f0e1525b388c0d174f611cc04af54153c5c4f36088c4"},
- {file = "sentencepiece-0.1.99-cp36-cp36m-win32.whl", hash = "sha256:47c378146928690d1bc106fdf0da768cebd03b65dd8405aa3dd88f9c81e35dba"},
- {file = "sentencepiece-0.1.99-cp36-cp36m-win_amd64.whl", hash = "sha256:9ba142e7a90dd6d823c44f9870abdad45e6c63958eb60fe44cca6828d3b69da2"},
- {file = "sentencepiece-0.1.99-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b7b1a9ae4d7c6f1f867e63370cca25cc17b6f4886729595b885ee07a58d3cec3"},
- {file = "sentencepiece-0.1.99-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d0f644c9d4d35c096a538507b2163e6191512460035bf51358794a78515b74f7"},
- {file = "sentencepiece-0.1.99-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c8843d23a0f686d85e569bd6dcd0dd0e0cbc03731e63497ca6d5bacd18df8b85"},
- {file = "sentencepiece-0.1.99-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:33e6f690a1caebb4867a2e367afa1918ad35be257ecdb3455d2bbd787936f155"},
- {file = "sentencepiece-0.1.99-cp37-cp37m-win32.whl", hash = "sha256:8a321866c2f85da7beac74a824b4ad6ddc2a4c9bccd9382529506d48f744a12c"},
- {file = "sentencepiece-0.1.99-cp37-cp37m-win_amd64.whl", hash = "sha256:c42f753bcfb7661c122a15b20be7f684b61fc8592c89c870adf52382ea72262d"},
- {file = "sentencepiece-0.1.99-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:85b476406da69c70586f0bb682fcca4c9b40e5059814f2db92303ea4585c650c"},
- {file = "sentencepiece-0.1.99-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cfbcfe13c69d3f87b7fcd5da168df7290a6d006329be71f90ba4f56bc77f8561"},
- {file = "sentencepiece-0.1.99-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:445b0ec381af1cd4eef95243e7180c63d9c384443c16c4c47a28196bd1cda937"},
- {file = "sentencepiece-0.1.99-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c6890ea0f2b4703f62d0bf27932e35808b1f679bdb05c7eeb3812b935ba02001"},
- {file = "sentencepiece-0.1.99-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fb71af492b0eefbf9f2501bec97bcd043b6812ab000d119eaf4bd33f9e283d03"},
- {file = "sentencepiece-0.1.99-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:27b866b5bd3ddd54166bbcbf5c8d7dd2e0b397fac8537991c7f544220b1f67bc"},
- {file = "sentencepiece-0.1.99-cp38-cp38-win32.whl", hash = "sha256:b133e8a499eac49c581c3c76e9bdd08c338cc1939e441fee6f92c0ccb5f1f8be"},
- {file = "sentencepiece-0.1.99-cp38-cp38-win_amd64.whl", hash = "sha256:0eaf3591dd0690a87f44f4df129cf8d05d8a4029b5b6709b489b8e27f9a9bcff"},
- {file = "sentencepiece-0.1.99-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:38efeda9bbfb55052d482a009c6a37e52f42ebffcea9d3a98a61de7aee356a28"},
- {file = "sentencepiece-0.1.99-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6c030b081dc1e1bcc9fadc314b19b740715d3d566ad73a482da20d7d46fd444c"},
- {file = "sentencepiece-0.1.99-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:84dbe53e02e4f8a2e45d2ac3e430d5c83182142658e25edd76539b7648928727"},
- {file = "sentencepiece-0.1.99-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b0f55d0a0ee1719b4b04221fe0c9f0c3461dc3dabd77a035fa2f4788eb3ef9a"},
- {file = "sentencepiece-0.1.99-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18e800f206cd235dc27dc749299e05853a4e4332e8d3dfd81bf13d0e5b9007d9"},
- {file = "sentencepiece-0.1.99-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ae1c40cda8f9d5b0423cfa98542735c0235e7597d79caf318855cdf971b2280"},
- {file = "sentencepiece-0.1.99-cp39-cp39-win32.whl", hash = "sha256:c84ce33af12ca222d14a1cdd37bd76a69401e32bc68fe61c67ef6b59402f4ab8"},
- {file = "sentencepiece-0.1.99-cp39-cp39-win_amd64.whl", hash = "sha256:350e5c74d739973f1c9643edb80f7cc904dc948578bcb1d43c6f2b173e5d18dd"},
- {file = "sentencepiece-0.1.99.tar.gz", hash = "sha256:189c48f5cb2949288f97ccdb97f0473098d9c3dcf5a3d99d4eabe719ec27297f"},
+ {file = "sentencepiece-0.2.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:188779e1298a1c8b8253c7d3ad729cb0a9891e5cef5e5d07ce4592c54869e227"},
+ {file = "sentencepiece-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bed9cf85b296fa2b76fc2547b9cbb691a523864cebaee86304c43a7b4cb1b452"},
+ {file = "sentencepiece-0.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d7b67e724bead13f18db6e1d10b6bbdc454af574d70efbb36f27d90387be1ca3"},
+ {file = "sentencepiece-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2fde4b08cfe237be4484c6c7c2e2c75fb862cfeab6bd5449ce4caeafd97b767a"},
+ {file = "sentencepiece-0.2.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4c378492056202d1c48a4979650981635fd97875a00eabb1f00c6a236b013b5e"},
+ {file = "sentencepiece-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1380ce6540a368de2ef6d7e6ba14ba8f3258df650d39ba7d833b79ee68a52040"},
+ {file = "sentencepiece-0.2.0-cp310-cp310-win32.whl", hash = "sha256:a1151d6a6dd4b43e552394aed0edfe9292820272f0194bd56c7c1660a0c06c3d"},
+ {file = "sentencepiece-0.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:d490142b0521ef22bc1085f061d922a2a6666175bb6b42e588ff95c0db6819b2"},
+ {file = "sentencepiece-0.2.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:17982700c4f6dbb55fa3594f3d7e5dd1c8659a274af3738e33c987d2a27c9d5c"},
+ {file = "sentencepiece-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7c867012c0e8bcd5bdad0f791609101cb5c66acb303ab3270218d6debc68a65e"},
+ {file = "sentencepiece-0.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7fd6071249c74f779c5b27183295b9202f8dedb68034e716784364443879eaa6"},
+ {file = "sentencepiece-0.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:27f90c55a65013cbb8f4d7aab0599bf925cde4adc67ae43a0d323677b5a1c6cb"},
+ {file = "sentencepiece-0.2.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b293734059ef656dcd65be62ff771507bea8fed0a711b6733976e1ed3add4553"},
+ {file = "sentencepiece-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e58b47f933aca74c6a60a79dcb21d5b9e47416256c795c2d58d55cec27f9551d"},
+ {file = "sentencepiece-0.2.0-cp311-cp311-win32.whl", hash = "sha256:c581258cf346b327c62c4f1cebd32691826306f6a41d8c4bec43b010dee08e75"},
+ {file = "sentencepiece-0.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:0993dbc665f4113017892f1b87c3904a44d0640eda510abcacdfb07f74286d36"},
+ {file = "sentencepiece-0.2.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:ea5f536e32ea8ec96086ee00d7a4a131ce583a1b18d130711707c10e69601cb2"},
+ {file = "sentencepiece-0.2.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:d0cb51f53b6aae3c36bafe41e86167c71af8370a039f542c43b0cce5ef24a68c"},
+ {file = "sentencepiece-0.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3212121805afc58d8b00ab4e7dd1f8f76c203ddb9dc94aa4079618a31cf5da0f"},
+ {file = "sentencepiece-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2a3149e3066c2a75e0d68a43eb632d7ae728c7925b517f4c05c40f6f7280ce08"},
+ {file = "sentencepiece-0.2.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:632f3594d3e7ac8b367bca204cb3fd05a01d5b21455acd097ea4c0e30e2f63d7"},
+ {file = "sentencepiece-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f295105c6bdbb05bd5e1b0cafbd78ff95036f5d3641e7949455a3f4e5e7c3109"},
+ {file = "sentencepiece-0.2.0-cp312-cp312-win32.whl", hash = "sha256:fb89f811e5efd18bab141afc3fea3de141c3f69f3fe9e898f710ae7fe3aab251"},
+ {file = "sentencepiece-0.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:7a673a72aab81fef5ebe755c6e0cc60087d1f3a4700835d40537183c1703a45f"},
+ {file = "sentencepiece-0.2.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:4547683f330289ec4f093027bfeb87f9ef023b2eb6f879fdc4a8187c7e0ffb90"},
+ {file = "sentencepiece-0.2.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7cd6175f7eaec7142d2bf6f6597ce7db4c9ac89acf93fcdb17410c3a8b781eeb"},
+ {file = "sentencepiece-0.2.0-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:859ba1acde782609a0910a26a60e16c191a82bf39b5621107552c0cd79fad00f"},
+ {file = "sentencepiece-0.2.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bcbbef6cc277f8f18f36959e305f10b1c620442d75addc79c21d7073ae581b50"},
+ {file = "sentencepiece-0.2.0-cp36-cp36m-win32.whl", hash = "sha256:536b934e244829e3fe6c4f198652cd82da48adb9aa145c9f00889542726dee3d"},
+ {file = "sentencepiece-0.2.0-cp36-cp36m-win_amd64.whl", hash = "sha256:0a91aaa3c769b52440df56fafda683b3aa48e3f2169cf7ee5b8c8454a7f3ae9b"},
+ {file = "sentencepiece-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:787e480ca4c1d08c9985a7eb1eae4345c107729c99e9b5a9a00f2575fc7d4b4b"},
+ {file = "sentencepiece-0.2.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f4d158189eb2ecffea3a51edf6d25e110b3678ec47f1a40f2d541eafbd8f6250"},
+ {file = "sentencepiece-0.2.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d1e5ca43013e8935f25457a4fca47e315780172c3e821b4b13a890668911c792"},
+ {file = "sentencepiece-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7140d9e5a74a0908493bb4a13f1f16a401297bd755ada4c707e842fbf6f0f5bf"},
+ {file = "sentencepiece-0.2.0-cp37-cp37m-win32.whl", hash = "sha256:6cf333625234f247ab357b0bd9836638405ea9082e1543d5b8408f014979dcbf"},
+ {file = "sentencepiece-0.2.0-cp37-cp37m-win_amd64.whl", hash = "sha256:ff88712338b01031910e8e61e7239aff3ce8869ee31a47df63cb38aadd591bea"},
+ {file = "sentencepiece-0.2.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:20813a68d4c221b1849c62c30e1281ea81687894d894b8d4a0f4677d9311e0f5"},
+ {file = "sentencepiece-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:926ef920ae2e8182db31d3f5d081ada57804e3e1d3a8c4ef8b117f9d9fb5a945"},
+ {file = "sentencepiece-0.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:89f65f69636b7e9c015b79dff9c9985a9bc7d19ded6f79ef9f1ec920fdd73ecf"},
+ {file = "sentencepiece-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0f67eae0dbe6f2d7d6ba50a354623d787c99965f068b81e145d53240198021b0"},
+ {file = "sentencepiece-0.2.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:98501e075f35dd1a1d5a20f65be26839fcb1938752ec61539af008a5aa6f510b"},
+ {file = "sentencepiece-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e3d1d2cc4882e8d6a1adf9d5927d7716f80617fc693385661caff21888972269"},
+ {file = "sentencepiece-0.2.0-cp38-cp38-win32.whl", hash = "sha256:b99a308a2e5e569031ab164b74e6fab0b6f37dfb493c32f7816225f4d411a6dd"},
+ {file = "sentencepiece-0.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:cdb701eec783d3ec86b7cd4c763adad8eaf6b46db37ee1c36e5e6c44b3fe1b5f"},
+ {file = "sentencepiece-0.2.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:1e0f9c4d0a6b0af59b613175f019916e28ade076e21242fd5be24340d8a2f64a"},
+ {file = "sentencepiece-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:298f21cc1366eb60311aedba3169d30f885c363ddbf44214b0a587d2908141ad"},
+ {file = "sentencepiece-0.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3f1ec95aa1e5dab11f37ac7eff190493fd87770f7a8b81ebc9dd768d1a3c8704"},
+ {file = "sentencepiece-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7b06b70af54daa4b4904cbb90b4eb6d35c9f3252fdc86c9c32d5afd4d30118d8"},
+ {file = "sentencepiece-0.2.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:22e37bac44dd6603388cb598c64ff7a76e41ca774646f21c23aadfbf5a2228ab"},
+ {file = "sentencepiece-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0461324897735512a32d222e3d886e24ad6a499761952b6bda2a9ee6e4313ea5"},
+ {file = "sentencepiece-0.2.0-cp39-cp39-win32.whl", hash = "sha256:38aed822fb76435fa1f12185f10465a94ab9e51d5e8a9159e9a540ce926f0ffd"},
+ {file = "sentencepiece-0.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:d8cf876516548b5a1d6ac4745d8b554f5c07891d55da557925e5c13ff0b4e6ad"},
+ {file = "sentencepiece-0.2.0.tar.gz", hash = "sha256:a52c19171daaf2e697dc6cbe67684e0fa341b1248966f6aebb541de654d15843"},
]
[[package]]
@@ -1194,4 +1201,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = ">=3.9"
-content-hash = "c8c4cc87637266a7b85debcbafa8887c5ad81cc8ef40e98a3f52c7c50af05c03"
+content-hash = "8e03f3a9b833fd86890a318a86d42dc4ca71353bc08af5dffd98efddf59f7e2b"
diff --git a/pyproject.toml b/pyproject.toml
index 25e2e20b24896..07dfbdee784a0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,11 +17,11 @@ classifiers = [
[tool.poetry.dependencies]
python = ">=3.9"
numpy = "^1.25.0"
-sentencepiece = ">=0.1.98,<0.2.0"
transformers = ">=4.35.2,<5.0.0"
protobuf = ">=4.21.0,<5.0.0"
gguf = { path = "./gguf-py" }
torch = { version = "^2.2.0", source = "pytorch" }
+sentencepiece = "^0.2.0"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
From fe883305c317779e80c64bb901f14e385be4689e Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Fri, 19 Jul 2024 14:38:17 -0400
Subject: [PATCH 18/19] chore : Add gguf_template to poetry scripts
Signed-off-by: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
---
gguf-py/pyproject.toml | 1 +
1 file changed, 1 insertion(+)
diff --git a/gguf-py/pyproject.toml b/gguf-py/pyproject.toml
index 471c8aa67af29..4241c5c17cbbb 100644
--- a/gguf-py/pyproject.toml
+++ b/gguf-py/pyproject.toml
@@ -37,3 +37,4 @@ gguf-convert-endian = "scripts:gguf_convert_endian_entrypoint"
gguf-dump = "scripts:gguf_dump_entrypoint"
gguf-set-metadata = "scripts:gguf_set_metadata_entrypoint"
gguf-new-metadata = "scripts:gguf_new_metadata_entrypoint"
+gguf-template = "scripts:gguf_template"
From a083c6cf6d2ac761173287124ee051eb6acc634d Mon Sep 17 00:00:00 2001
From: teleprint-me <77757836+teleprint-me@users.noreply.github.com>
Date: Fri, 19 Jul 2024 14:53:56 -0400
Subject: [PATCH 19/19] chore : Add gguf template entrypoint to scripts sub
package and fix toml entry
---
gguf-py/pyproject.toml | 2 +-
gguf-py/scripts/__init__.py | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/gguf-py/pyproject.toml b/gguf-py/pyproject.toml
index 4241c5c17cbbb..42c312c8030c2 100644
--- a/gguf-py/pyproject.toml
+++ b/gguf-py/pyproject.toml
@@ -37,4 +37,4 @@ gguf-convert-endian = "scripts:gguf_convert_endian_entrypoint"
gguf-dump = "scripts:gguf_dump_entrypoint"
gguf-set-metadata = "scripts:gguf_set_metadata_entrypoint"
gguf-new-metadata = "scripts:gguf_new_metadata_entrypoint"
-gguf-template = "scripts:gguf_template"
+gguf-template = "scripts:gguf_template_entrypoint"
diff --git a/gguf-py/scripts/__init__.py b/gguf-py/scripts/__init__.py
index e77f2e9c97c31..7d75bae46dfb7 100644
--- a/gguf-py/scripts/__init__.py
+++ b/gguf-py/scripts/__init__.py
@@ -4,3 +4,4 @@
from .gguf_dump import main as gguf_dump_entrypoint
from .gguf_set_metadata import main as gguf_set_metadata_entrypoint
from .gguf_new_metadata import main as gguf_new_metadata_entrypoint
+from .gguf_template import main as gguf_template_entrypoint