sakthi54321 commited on
Commit
bbebc97
·
verified ·
1 Parent(s): acc721c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -8,22 +8,21 @@ MODEL_ID = "sakthi54321/power_NLP"
8
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
9
  model = AutoModelForCausalLM.from_pretrained(
10
  MODEL_ID,
11
- torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
12
  device_map="auto"
13
  )
14
 
 
15
  generator = pipeline(
16
  "text-generation",
17
  model=model,
18
- tokenizer=tokenizer,
19
- device=0 if torch.cuda.is_available() else -1
20
  )
21
 
22
  # Chat function
23
  def chat_fn(message, history):
24
- prompt = message
25
  outputs = generator(
26
- prompt,
27
  max_new_tokens=200,
28
  temperature=0.7,
29
  top_p=0.9,
 
8
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
9
  model = AutoModelForCausalLM.from_pretrained(
10
  MODEL_ID,
11
+ dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
12
  device_map="auto"
13
  )
14
 
15
+ # Build pipeline (❌ no device arg here!)
16
  generator = pipeline(
17
  "text-generation",
18
  model=model,
19
+ tokenizer=tokenizer
 
20
  )
21
 
22
  # Chat function
23
  def chat_fn(message, history):
 
24
  outputs = generator(
25
+ message,
26
  max_new_tokens=200,
27
  temperature=0.7,
28
  top_p=0.9,