ZennyKenny commited on
Commit
5a2fadd
Β·
verified Β·
1 Parent(s): fd8bbb7

use pipeline instead of direct model load

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -16,15 +16,14 @@ import os
16
  hf_api_key = os.getenv("API_KEY")
17
  login(token=hf_api_key)
18
 
19
- pipe = pipeline("text-generation", model="mistralai/Mistral-Small-24B-Base-2501")
20
 
21
  # Function to classify customer comments
22
- @spaces.GPU
23
  def classify_comments():
24
  results = []
25
  for comment in df['customer_comment']:
26
- prompt = f"Classify this customer feedback: '{comment}' into one of the following categories: Price of Service, Quality of Customer Support, Product Experience. Please only respond with the category name and nothing else."
27
- category = pipe(prompt, max_length=30)[0]['generated_text']
28
  results.append(category)
29
  df['comment_category'] = results
30
  return df[['customer_comment', 'comment_category']].to_html(index=False)
 
16
  hf_api_key = os.getenv("API_KEY")
17
  login(token=hf_api_key)
18
 
19
+ pipe = pipeline("text-classification", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
20
 
21
  # Function to classify customer comments
 
22
  def classify_comments():
23
  results = []
24
  for comment in df['customer_comment']:
25
+ prompt = comment
26
+ category = pipe(prompt)[0]['label']
27
  results.append(category)
28
  df['comment_category'] = results
29
  return df[['customer_comment', 'comment_category']].to_html(index=False)