Khushali-shah commited on
Commit
a16bb2d
·
verified ·
1 Parent(s): b81147d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -31
app.py CHANGED
@@ -8,34 +8,10 @@ model = AutoModelForCausalLM.from_pretrained("hiraltalsaniya/phi2-task-classific
8
  tokenizer = AutoTokenizer.from_pretrained("hiraltalsaniya/phi2-task-classification-demo", trust_remote_code=True)
9
 
10
  def classify(text):
11
- # prompt_template = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
12
- # ### Instruction: Categorize the IT task description into one of the 6 categories:
13
-
14
- # Client Meeting\nDevelopment\nInternal Meeting\nInterview\nLearning\nReview
15
-
16
- # ### User Input:
17
- # {}
18
- # ### Response:
19
- # """
20
-
21
- # user_input = f"{text}"
22
- # prompt = prompt_template.format(user_input)
23
-
24
- # inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False)
25
- # outputs = model.generate(**inputs, max_length=200)
26
- # text = tokenizer.batch_decode(outputs)[0]
27
- # return text
28
-
29
-
30
  prompt_template = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
31
  ### Instruction: Categorize the IT task description into one of the 6 categories:
32
 
33
- Client Meeting
34
- Development
35
- Internal Meeting
36
- Interview
37
- Learning
38
- Review
39
 
40
  ### User Input:
41
  {}
@@ -45,12 +21,36 @@ def classify(text):
45
  user_input = f"{text}"
46
  prompt = prompt_template.format(user_input)
47
 
48
- # The rest of your code remains unchanged
49
- inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=True)
50
- outputs = model.generate(**inputs, max_length=200, pad_token_id=tokenizer.eos_token_id)
51
- response_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
52
- # print(response_text)
53
- return response_text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  description = "This AI model is trained to classify texts."
56
  title = "Classify Your Texts"
 
8
  tokenizer = AutoTokenizer.from_pretrained("hiraltalsaniya/phi2-task-classification-demo", trust_remote_code=True)
9
 
10
  def classify(text):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  prompt_template = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
12
  ### Instruction: Categorize the IT task description into one of the 6 categories:
13
 
14
+ Client Meeting\nDevelopment\nInternal Meeting\nInterview\nLearning\nReview
 
 
 
 
 
15
 
16
  ### User Input:
17
  {}
 
21
  user_input = f"{text}"
22
  prompt = prompt_template.format(user_input)
23
 
24
+ inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False)
25
+ outputs = model.generate(**inputs, max_length=200)
26
+ text = tokenizer.batch_decode(outputs)[0]
27
+ return text
28
+
29
+
30
+ # prompt_template = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
31
+ # ### Instruction: Categorize the IT task description into one of the 6 categories:
32
+
33
+ # Client Meeting
34
+ # Development
35
+ # Internal Meeting
36
+ # Interview
37
+ # Learning
38
+ # Review
39
+
40
+ # ### User Input:
41
+ # {}
42
+ # ### Response:
43
+ # """
44
+
45
+ # user_input = f"{text}"
46
+ # prompt = prompt_template.format(user_input)
47
+
48
+ # # The rest of your code remains unchanged
49
+ # inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=True)
50
+ # outputs = model.generate(**inputs, max_length=200, pad_token_id=tokenizer.eos_token_id)
51
+ # response_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
52
+ # # print(response_text)
53
+ # return response_text
54
 
55
  description = "This AI model is trained to classify texts."
56
  title = "Classify Your Texts"