willsh1997 commited on
Commit
2cdd8fc
Β·
1 Parent(s): 0b66803

:wrench: updates for deployment

Browse files
Files changed (3) hide show
  1. README.md +3 -3
  2. carbon_footprint_gradio.py +4 -21
  3. emissions.csv +2 -1
README.md CHANGED
@@ -1,14 +1,14 @@
1
  ---
2
- title: Linkedin Generator
3
  emoji: πŸ†
4
  colorFrom: red
5
  colorTo: green
6
  sdk: gradio
7
  sdk_version: 5.23.3
8
- app_file: linkedin_gradio.py
9
  pinned: false
10
  license: apache-2.0
11
- short_description: generates linkedin posts from freetext entries
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Carbon Footprint Widget
3
  emoji: πŸ†
4
  colorFrom: red
5
  colorTo: green
6
  sdk: gradio
7
  sdk_version: 5.23.3
8
+ app_file: carbon_footprint_gradio.py
9
  pinned: false
10
  license: apache-2.0
11
+ short_description: measures CO2e generated from a single query to an LLM
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
carbon_footprint_gradio.py CHANGED
@@ -37,7 +37,7 @@ llama32_3b_pipe = pipeline(
37
  def llama32_3b_chat(message) -> str:
38
  "simplifies pipeline output to only return generated text"
39
  with EmissionsTracker() as tracker:
40
- input_history = [{"role": "system", "content": """You are now a LinkedIn post generator. I will just give you a fraction of an idea and you will convert it into a buzzing LinkedIn post full of emojis and excitement, just like every other LinkedIn post.
41
  """}]
42
  input_history.append({"role": "user", "content": f"{message}"})
43
  ##add sth about context window here
@@ -46,24 +46,7 @@ def llama32_3b_chat(message) -> str:
46
  input_history,
47
  max_new_tokens=512
48
  )
49
- return outputs[-1]['generated_text'][-1]['content'], f"This query generated {tracker.final_emissions*1000} grams of CO2eq"
50
-
51
-
52
- # ### EMISSIONS TRACKING
53
-
54
-
55
- # from codecarbon import EmissionsTracker
56
- # tracker = EmissionsTracker()
57
- # tracker.start()
58
- # try:
59
- # # Compute intensive code goes here
60
- # _ = 1 + 1
61
- # finally:
62
- # tracker.stop()
63
-
64
-
65
-
66
-
67
 
68
 
69
  # Create the Gradio interface
@@ -71,9 +54,9 @@ def create_interface():
71
 
72
  with gr.Blocks() as demo:
73
  with gr.Row():
74
- text_input = gr.Textbox(label="input for Linkedin Post Generator", value = "I was sleepy at work today.")
75
  with gr.Row():
76
- submit_btn = gr.Button("Generate LinkedIn Post")
77
  with gr.Row():
78
  text_output = gr.Textbox(interactive=False)
79
  with gr.Row():
 
37
  def llama32_3b_chat(message) -> str:
38
  "simplifies pipeline output to only return generated text"
39
  with EmissionsTracker() as tracker:
40
+ input_history = [{"role": "system", "content": """You are a helpful chatbot assistant. You will answer all queries as best you can.
41
  """}]
42
  input_history.append({"role": "user", "content": f"{message}"})
43
  ##add sth about context window here
 
46
  input_history,
47
  max_new_tokens=512
48
  )
49
+ return outputs[-1]['generated_text'][-1]['content'], f"This query generated {tracker.final_emissions*1000:.4f} grams of CO2eq"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
 
52
  # Create the Gradio interface
 
54
 
55
  with gr.Blocks() as demo:
56
  with gr.Row():
57
+ text_input = gr.Textbox(label="Query", value = "What is the meaning of life?")
58
  with gr.Row():
59
+ submit_btn = gr.Button("Generate response")
60
  with gr.Row():
61
  text_output = gr.Textbox(interactive=False)
62
  with gr.Row():
emissions.csv CHANGED
@@ -3,4 +3,5 @@ timestamp,project_name,run_id,experiment_id,duration,emissions,emissions_rate,cp
3
  2025-06-18T21:18:42,codecarbon,93cd7868-abce-4ef6-bdbb-2a67d132b39e,5b0fa12a-3dd7-45bb-9766-cc326314d9f1,46.81101042900264,0.0003212732825805,6.863199055867797e-06,4.500000000000002,46.93939773164349,10.0,5.597157877499742e-05,0.000405178379698,0.0001243757692222,0.0005855257276952,Australia,AUS,queensland,,,Linux-6.6.87.1-microsoft-standard-WSL2-x86_64-with-glibc2.35,3.10.12,3.0.2,16,Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz,1,1 x NVIDIA GeForce RTX 3070 Laptop GPU,153.0197,-27.4417,15.496288299560549,machine,N,1.0
4
  2025-06-18T21:49:22,codecarbon,dbbf6de0-6a1f-4973-8994-d3c7966ab2ec,5b0fa12a-3dd7-45bb-9766-cc326314d9f1,34.803390808003314,0.0002660291573882,7.64377123067678e-06,4.500000000000002,38.56113153342519,10.0,4.1601253318740425e-05,0.0003507980584159,9.24431087638772e-05,0.0004848424204985,Australia,AUS,queensland,,,Linux-6.6.87.1-microsoft-standard-WSL2-x86_64-with-glibc2.35,3.10.12,3.0.2,16,Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz,1,1 x NVIDIA GeForce RTX 3070 Laptop GPU,153.0197,-27.4417,15.496288299560549,machine,N,1.0
5
  2025-06-18T22:19:41,codecarbon,e2a2805e-a60c-4803-8bcb-7e52e8d35079,5b0fa12a-3dd7-45bb-9766-cc326314d9f1,57.62264490999951,0.0003971889774521,6.892932076834336e-06,4.500000000000002,37.57034763815363,10.0,6.95037808675079e-05,0.0004999320666119,0.0001544474558166,0.0007238833032961,Australia,AUS,queensland,,,Linux-6.6.87.1-microsoft-standard-WSL2-x86_64-with-glibc2.35,3.10.12,3.0.2,16,Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz,1,1 x NVIDIA GeForce RTX 3070 Laptop GPU,153.0197,-27.4417,15.496288299560549,machine,N,1.0
6
- 2025-06-18T22:20:34,codecarbon,7c42284d-772f-41d6-bdbe-0ecd0aa7a5fe,5b0fa12a-3dd7-45bb-9766-cc326314d9f1,39.92492737899738,0.0003132606914300843,7.84624323687251e-06,4.500000000000002,38.242864773767025,10.0,4.80197628712631e-05,0.0004161967218459517,0.00010670616666112539,0.0005709226513783402,Australia,AUS,queensland,,,Linux-6.6.87.1-microsoft-standard-WSL2-x86_64-with-glibc2.35,3.10.12,3.0.2,16,Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz,1,1 x NVIDIA GeForce RTX 3070 Laptop GPU,153.0197,-27.4417,15.496288299560547,machine,N,1.0
 
 
3
  2025-06-18T21:18:42,codecarbon,93cd7868-abce-4ef6-bdbb-2a67d132b39e,5b0fa12a-3dd7-45bb-9766-cc326314d9f1,46.81101042900264,0.0003212732825805,6.863199055867797e-06,4.500000000000002,46.93939773164349,10.0,5.597157877499742e-05,0.000405178379698,0.0001243757692222,0.0005855257276952,Australia,AUS,queensland,,,Linux-6.6.87.1-microsoft-standard-WSL2-x86_64-with-glibc2.35,3.10.12,3.0.2,16,Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz,1,1 x NVIDIA GeForce RTX 3070 Laptop GPU,153.0197,-27.4417,15.496288299560549,machine,N,1.0
4
  2025-06-18T21:49:22,codecarbon,dbbf6de0-6a1f-4973-8994-d3c7966ab2ec,5b0fa12a-3dd7-45bb-9766-cc326314d9f1,34.803390808003314,0.0002660291573882,7.64377123067678e-06,4.500000000000002,38.56113153342519,10.0,4.1601253318740425e-05,0.0003507980584159,9.24431087638772e-05,0.0004848424204985,Australia,AUS,queensland,,,Linux-6.6.87.1-microsoft-standard-WSL2-x86_64-with-glibc2.35,3.10.12,3.0.2,16,Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz,1,1 x NVIDIA GeForce RTX 3070 Laptop GPU,153.0197,-27.4417,15.496288299560549,machine,N,1.0
5
  2025-06-18T22:19:41,codecarbon,e2a2805e-a60c-4803-8bcb-7e52e8d35079,5b0fa12a-3dd7-45bb-9766-cc326314d9f1,57.62264490999951,0.0003971889774521,6.892932076834336e-06,4.500000000000002,37.57034763815363,10.0,6.95037808675079e-05,0.0004999320666119,0.0001544474558166,0.0007238833032961,Australia,AUS,queensland,,,Linux-6.6.87.1-microsoft-standard-WSL2-x86_64-with-glibc2.35,3.10.12,3.0.2,16,Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz,1,1 x NVIDIA GeForce RTX 3070 Laptop GPU,153.0197,-27.4417,15.496288299560549,machine,N,1.0
6
+ 2025-06-18T22:20:34,codecarbon,7c42284d-772f-41d6-bdbe-0ecd0aa7a5fe,5b0fa12a-3dd7-45bb-9766-cc326314d9f1,39.92492737899738,0.00031326069143,7.84624323687251e-06,4.500000000000002,38.24286477376703,10.0,4.80197628712631e-05,0.0004161967218459,0.0001067061666611,0.0005709226513783,Australia,AUS,queensland,,,Linux-6.6.87.1-microsoft-standard-WSL2-x86_64-with-glibc2.35,3.10.12,3.0.2,16,Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz,1,1 x NVIDIA GeForce RTX 3070 Laptop GPU,153.0197,-27.4417,15.496288299560549,machine,N,1.0
7
+ 2025-06-19T13:44:24,codecarbon,d2a8fe34-0e3e-4498-95bc-5cb587988a73,5b0fa12a-3dd7-45bb-9766-cc326314d9f1,101.61988382600066,0.0007264906608616548,7.1490995020776975e-06,4.500000000000002,35.51655846560717,10.0,0.00012256610360374684,0.000929116298847954,0.00027235851824999473,0.0013240409207016955,Australia,AUS,queensland,,,Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.35,3.10.12,3.0.2,16,Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz,1,1 x NVIDIA GeForce RTX 3070 Laptop GPU,152.9977,-27.3778,15.496265411376953,machine,N,1.0