Kavyaah commited on
Commit
e3eaa58
·
verified ·
1 Parent(s): 4ba9027

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +14 -7
README.md CHANGED
@@ -33,23 +33,30 @@ Context Length 2048 tokens
33
  #
34
  from transformers import AutoTokenizer, AutoModelForCausalLM
35
  import torch
36
-
37
  # Load tokenizer & model
38
  tokenizer = AutoTokenizer.from_pretrained("Kavyaah/copywriting-llm")
39
  model = AutoModelForCausalLM.from_pretrained("Kavyaah/copywriting-llm", torch_dtype="auto")
40
  model.eval()
41
-
42
  # Function to generate push notification
43
  def generate_copy(brand, offer, tone="fun", max_new_tokens=40):
44
  prompt = f"""You are an expert marketing copywriter.
45
  Write a short, catchy push notification in a {tone} tone.
46
  It should promote {brand}'s offer: "{offer}".
47
  Keep it under 20 words, engaging, and persuasive."""
48
- inputs = tokenizer(prompt, return_tensors="pt")
49
- with torch.no_grad():
50
- outputs = model.generate(**inputs, max_new_tokens=max_new_tokens, temperature=0.9, top_p=0.9, do_sample=True)
51
- return tokenizer.decode(outputs[0], skip_special_tokens=True)
52
-
 
 
 
 
 
 
 
53
  # Example
54
  print(generate_copy("Zomato", "Flat 60% off on dinner combos this weekend!"))
55
  #
 
33
  #
34
  from transformers import AutoTokenizer, AutoModelForCausalLM
35
  import torch
36
+
37
  # Load tokenizer & model
38
  tokenizer = AutoTokenizer.from_pretrained("Kavyaah/copywriting-llm")
39
  model = AutoModelForCausalLM.from_pretrained("Kavyaah/copywriting-llm", torch_dtype="auto")
40
  model.eval()
41
+
42
  # Function to generate push notification
43
  def generate_copy(brand, offer, tone="fun", max_new_tokens=40):
44
  prompt = f"""You are an expert marketing copywriter.
45
  Write a short, catchy push notification in a {tone} tone.
46
  It should promote {brand}'s offer: "{offer}".
47
  Keep it under 20 words, engaging, and persuasive."""
48
+
49
+ inputs = tokenizer(prompt, return_tensors="pt")
50
+ with torch.no_grad():
51
+ outputs = model.generate(
52
+ **inputs,
53
+ max_new_tokens=max_new_tokens,
54
+ temperature=0.9,
55
+ top_p=0.9,
56
+ do_sample=True
57
+ )
58
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
59
+
60
  # Example
61
  print(generate_copy("Zomato", "Flat 60% off on dinner combos this weekend!"))
62
  #