Spaces:
Running
Running
simplify script
Browse files- summarize_transcript.py +20 -7
summarize_transcript.py
CHANGED
|
@@ -8,13 +8,13 @@ import argparse
|
|
| 8 |
from llama_cpp import Llama
|
| 9 |
from huggingface_hub import hf_hub_download
|
| 10 |
|
| 11 |
-
def load_model():
|
| 12 |
"""Load the model from Hugging Face Hub."""
|
| 13 |
|
| 14 |
# Initialize the model with SYCL support
|
| 15 |
llm = Llama.from_pretrained(
|
| 16 |
-
repo_id=
|
| 17 |
-
filename=
|
| 18 |
n_gpu_layers=-1, # Use all layers on GPU
|
| 19 |
seed=1337,
|
| 20 |
n_ctx=32768, # Context size
|
|
@@ -84,14 +84,27 @@ def stream_summarize_transcript(llm, transcript):
|
|
| 84 |
|
| 85 |
|
| 86 |
def main():
|
| 87 |
-
parser = argparse.ArgumentParser(description="Summarize transcript
|
| 88 |
-
parser.add_argument("-i", "--input", type=str,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
args = parser.parse_args()
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
# Load the model
|
| 94 |
-
llm = load_model()
|
| 95 |
|
| 96 |
# Read the transcript
|
| 97 |
transcript_path = args.input
|
|
|
|
| 8 |
from llama_cpp import Llama
|
| 9 |
from huggingface_hub import hf_hub_download
|
| 10 |
|
| 11 |
+
def load_model(repo_id, filename):
|
| 12 |
"""Load the model from Hugging Face Hub."""
|
| 13 |
|
| 14 |
# Initialize the model with SYCL support
|
| 15 |
llm = Llama.from_pretrained(
|
| 16 |
+
repo_id=repo_id,
|
| 17 |
+
filename=filename,
|
| 18 |
n_gpu_layers=-1, # Use all layers on GPU
|
| 19 |
seed=1337,
|
| 20 |
n_ctx=32768, # Context size
|
|
|
|
| 84 |
|
| 85 |
|
| 86 |
def main():
|
| 87 |
+
parser = argparse.ArgumentParser(description="Summarize transcript in zh-TW using a GGUF model.")
|
| 88 |
+
parser.add_argument("-i", "--input", type=str,
|
| 89 |
+
default="./transcripts/short.txt",
|
| 90 |
+
help="Path to the input transcript file (default: ./transcripts/short.txt)")
|
| 91 |
+
parser.add_argument("-m", "--model", type=str,
|
| 92 |
+
default="Luigi/Falcon-H1-Tiny-Multilingual-100M-Instruct-GGUF:IQ4_NL",
|
| 93 |
+
help="HuggingFace model in format repo_id:quant (e.g., Luigi/Falcon-H1-Tiny-Multilingual-100M-Instruct-GGUF:IQ4_NL)")
|
| 94 |
args = parser.parse_args()
|
| 95 |
|
| 96 |
+
# Parse model argument if provided
|
| 97 |
+
if ":" in args.model:
|
| 98 |
+
repo_id, quant = args.model.rsplit(":", 1)
|
| 99 |
+
filename = f"*{quant}.gguf"
|
| 100 |
+
else:
|
| 101 |
+
print(f"Error: Invalid model format '{args.model}'. Expected format: repo_id:quant")
|
| 102 |
+
return
|
| 103 |
+
|
| 104 |
+
print(f"Loading model: {repo_id} ({filename}) with SYCL acceleration...")
|
| 105 |
|
| 106 |
# Load the model
|
| 107 |
+
llm = load_model(repo_id, filename)
|
| 108 |
|
| 109 |
# Read the transcript
|
| 110 |
transcript_path = args.input
|