Spaces:
Running
on
Zero
Running
on
Zero
malvin noel
commited on
Commit
·
1e3c8be
1
Parent(s):
469a509
Best prompt and model
Browse files- scripts/generate_scripts.py +11 -8
scripts/generate_scripts.py
CHANGED
@@ -13,7 +13,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
13 |
|
14 |
@spaces.GPU()
|
15 |
def generate_local(prompt: str, max_new_tokens: int = 350, temperature: float = 0.7) -> str:
|
16 |
-
model_id = "Qwen/Qwen2.5-
|
17 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # get the device the model is on
|
18 |
|
19 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
@@ -33,13 +33,16 @@ def generate_local(prompt: str, max_new_tokens: int = 350, temperature: float =
|
|
33 |
|
34 |
def generate_script(prompt: str, word_count: int = 60) -> str:
|
35 |
system_prompt = (
|
36 |
-
"You are
|
37 |
-
"
|
38 |
-
f"
|
39 |
-
|
40 |
-
"
|
41 |
-
"Only
|
42 |
-
"
|
|
|
|
|
|
|
43 |
)
|
44 |
return generate_local(system_prompt)
|
45 |
|
|
|
13 |
|
14 |
@spaces.GPU()
|
15 |
def generate_local(prompt: str, max_new_tokens: int = 350, temperature: float = 0.7) -> str:
|
16 |
+
model_id = "Qwen/Qwen2.5-3B"
|
17 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # get the device the model is on
|
18 |
|
19 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
|
|
33 |
|
34 |
def generate_script(prompt: str, word_count: int = 60) -> str:
|
35 |
system_prompt = (
|
36 |
+
"You are an expert YouTube scriptwriter. "
|
37 |
+
"Your job is to write the EXACT words that will be spoken aloud in a video. "
|
38 |
+
f"Topic: {prompt.strip()}\n\n"
|
39 |
+
"🎯 Output rules:\n"
|
40 |
+
f"- Exactly {word_count} words.\n"
|
41 |
+
"- Only the spoken words. NO scene descriptions, instructions, or formatting.\n"
|
42 |
+
"- Write in natural, clear, and simple English, as if it's being said by a voiceover artist.\n"
|
43 |
+
"- Keep a steady rhythm (about 2 words per second).\n"
|
44 |
+
"- Do NOT include any explanations, labels, or headers. Only output the final spoken script.\n\n"
|
45 |
+
"Start now:"
|
46 |
)
|
47 |
return generate_local(system_prompt)
|
48 |
|