carloscc10 commited on
Commit
a137c56
·
verified ·
1 Parent(s): 1d44af7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -1,9 +1,16 @@
1
  import random
 
 
2
 
 
 
 
 
3
  CV_CONTEXT = """
4
- Carlos Collado Capell is a top‑ranked MSc student at EPFL (#1/159), AI Research Intern at ESA (first author, pretrained foundation models), Data Science Intern in Silicon Valley (boosted forecast accuracy by 10%), published in Renewable Energy, and multi‑award winner for academic excellence.
5
  """
6
 
 
7
  COMEDIC_STYLES = [
8
  "outrageously funny and majestic style, like a disco‑dancing unicorn delivering a TED talk",
9
  "absurdly witty and cosmic style, as if Shakespeare wrote a stand‑up routine from Mars",
@@ -14,7 +21,6 @@ COMEDIC_STYLES = [
14
  def generate_completion(prompt):
15
  style = random.choice(COMEDIC_STYLES)
16
  full_prompt = f"{CV_CONTEXT}\nComplete the sentence in a {style}:\n\"{prompt}\""
17
-
18
  outputs = generator(
19
  full_prompt,
20
  max_length=80,
@@ -23,5 +29,16 @@ def generate_completion(prompt):
23
  top_k=60,
24
  top_p=0.95
25
  )
26
- text = outputs[0]["generated_text"]
27
- return text.split(prompt, 1)[1].strip()
 
 
 
 
 
 
 
 
 
 
 
 
1
  import random
2
+ import gradio as gr
3
+ from transformers import pipeline
4
 
5
+ # — Load a lightweight but expressive model
6
+ generator = pipeline("text-generation", model="EleutherAI/gpt-neo-125M")
7
+
8
+ # — A concise CV summary to ground each completion in your real achievements
9
  CV_CONTEXT = """
10
+ Carlos Collado Capell is a top‑ranked MSc student at EPFL (#1/159), AI Research Intern at ESA (first author on a foundation‑model paper), Data Science Intern in Silicon Valley (boosted load forecasts by 10%), published Renewable Energy author, and multi‑award winner for academic excellence.
11
  """
12
 
13
+ # — A handful of absurdly funny “styles” for variety
14
  COMEDIC_STYLES = [
15
  "outrageously funny and majestic style, like a disco‑dancing unicorn delivering a TED talk",
16
  "absurdly witty and cosmic style, as if Shakespeare wrote a stand‑up routine from Mars",
 
21
  def generate_completion(prompt):
22
  style = random.choice(COMEDIC_STYLES)
23
  full_prompt = f"{CV_CONTEXT}\nComplete the sentence in a {style}:\n\"{prompt}\""
 
24
  outputs = generator(
25
  full_prompt,
26
  max_length=80,
 
29
  top_k=60,
30
  top_p=0.95
31
  )
32
+ generated = outputs[0]["generated_text"]
33
+ # Return only the new part after the prompt
34
+ return generated.split(prompt, 1)[1].strip()
35
+
36
+ iface = gr.Interface(
37
+ fn=generate_completion,
38
+ inputs=gr.Textbox(lines=1, placeholder="Type: You will love collaborating with Carlos because"),
39
+ outputs="text",
40
+ title="Carlos’ Portfolio Autocomplete",
41
+ description="Generates an over‑the‑top funny reason why you’ll love collaborating with Carlos — based on his CV!"
42
+ )
43
+
44
+ iface.launch()