malvin noel commited on
Commit
1e3c8be
·
1 Parent(s): 469a509

Best prompt and model

Browse files
Files changed (1) hide show
  1. 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-1.5B"
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 a professional scriptwriter. "
37
- "Generate the *exact spoken words* for a short narration in a YouTube video. "
38
- f"The topic is: {prompt.strip()}. "
39
- f"The script must be exactly {word_count} words long. "
40
- "Do NOT include stage directions, scene descriptions, or formatting. "
41
- "Only output the spoken words, as they should be said, in plain text. "
42
- "Make it clear, engaging, and natural for a voiceover."
 
 
 
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