nastasiasnk commited on
Commit
79e7eb6
·
verified ·
1 Parent(s): 4c1fe3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -3,6 +3,10 @@ import os
3
  from transformers import pipeline
4
  from huggingface_hub import HfFolder
5
 
 
 
 
 
6
  # Ensure the HF_TOKEN environment variable is set correctly
7
  HF_TOKEN = os.getenv('HF_TOKEN')
8
  if HF_TOKEN:
@@ -11,7 +15,15 @@ else:
11
  st.warning("HF_TOKEN is not set. Proceeding without a token.")
12
 
13
  # Use a valid model identifier
14
- generator = pipeline("text-generation", model="gpt2")
 
 
 
 
 
 
 
 
15
 
16
  st.title("Text Generation")
17
  st.write("Enter your text below.")
 
3
  from transformers import pipeline
4
  from huggingface_hub import HfFolder
5
 
6
+ import transformers
7
+ import torch
8
+
9
+
10
  # Ensure the HF_TOKEN environment variable is set correctly
11
  HF_TOKEN = os.getenv('HF_TOKEN')
12
  if HF_TOKEN:
 
15
  st.warning("HF_TOKEN is not set. Proceeding without a token.")
16
 
17
  # Use a valid model identifier
18
+ #generator = pipeline("text-generation", model="gpt2")
19
+
20
+
21
+ model_id = "meta-llama/Meta-Llama-3-8B"
22
+
23
+ generator = transformers.pipeline(
24
+ "text-generation", model=model_id, model_kwargs={"torch_dtype": torch.bfloat16}, device_map="auto"
25
+ )
26
+
27
 
28
  st.title("Text Generation")
29
  st.write("Enter your text below.")