janny127 commited on
Commit
76a5b75
·
verified ·
1 Parent(s): ec6ee6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -37
app.py CHANGED
@@ -4,7 +4,7 @@ import gradio as gr
4
  from nltk.tokenize import sent_tokenize
5
  import torch
6
 
7
- model = "janny127/autotrain-7qmts-cs1er"
8
  tokenizer = AutoTokenizer.from_pretrained(model)
9
 
10
  pipeline = pipeline(
@@ -35,6 +35,8 @@ def predict(prompt, history):
35
  final_result = generated_text.split("### Assistant:")[1]
36
  if " Human: " in final_result:
37
  final_result = final_result.split(" Human: ")[0]
 
 
38
 
39
  # return generated_text.strip()
40
  return final_result.strip()
@@ -45,40 +47,4 @@ gr.ChatInterface(predict,
45
  examples=['How to cook a fish?', 'Who is the president of US now?']
46
  ).launch() # Launching the web interface.
47
 
48
- # interface = gr.ChatInterface(
49
- # fn=predict,
50
- # stop_btn=None
51
- # )
52
-
53
- # with gr.Blocks() as demo:
54
- # interface.render()
55
-
56
-
57
- # demo.launch()
58
-
59
- # def generate_answer(query, sample_num=3):
60
- # formatted_prompt = (
61
- # f"<|im_start|>user\n{query}<|im_end|>\n<|im_start|>assistant\n"
62
-
63
- # )
64
-
65
- # sequences = pipeline(
66
- # formatted_prompt,
67
- # do_sample=True,
68
- # top_k=50,
69
- # top_p = 0.9,
70
- # num_return_sequences=sample_num,
71
- # repetition_penalty=1.1,
72
- # max_new_tokens=150,
73
- # eos_token_id=CHAT_EOS_TOKEN_ID,
74
- # )
75
- # answers = list()
76
- # for seq in sequences:
77
- # answer = seq['generated_text'].replace(formatted_prompt, "")
78
- # answers.append(answer)
79
- # answer = sent_tokenize(answers[0])
80
- # final_answer = ''
81
- # for an in answer:
82
- # final_answer += an.strip()
83
- # return final_answer
84
 
 
4
  from nltk.tokenize import sent_tokenize
5
  import torch
6
 
7
+ model = "janny127/autotrain-pje3d-uvelc1"
8
  tokenizer = AutoTokenizer.from_pretrained(model)
9
 
10
  pipeline = pipeline(
 
35
  final_result = generated_text.split("### Assistant:")[1]
36
  if " Human: " in final_result:
37
  final_result = final_result.split(" Human: ")[0]
38
+ if " #" in final_result:
39
+ final_result = final_result.split(" #")[0]
40
 
41
  # return generated_text.strip()
42
  return final_result.strip()
 
47
  examples=['How to cook a fish?', 'Who is the president of US now?']
48
  ).launch() # Launching the web interface.
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50