lruizap commited on
Commit
dbd9832
โ€ข
1 Parent(s): 249d778

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -4
app.py CHANGED
@@ -9,11 +9,43 @@ tokenizer = AutoTokenizer.from_pretrained(
9
  model = AutoModelForSeq2SeqLM.from_pretrained(
10
  "Kaludi/chatgpt-gpt4-prompts-bart-large-cnn-samsum", from_tf=True)
11
 
 
 
12
 
13
- def generatePrompt(inputuno, inputdos):
 
14
 
15
- # zephyr
16
- pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-alpha",torch_dtype=torch.bfloat16, device_map="auto")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  prompt = inputuno
19
  promptdos = inputdos
@@ -49,6 +81,6 @@ examples = [["photographer"], ["developer"], ["teacher"], [
49
  "human resources staff"], ["recipe for ham croquettes"]]
50
  description = ""
51
 
52
- PerfectGPT = gr.Interface(generatePrompt, inputs=[input_prompt, input_promptdos], outputs=output_component, examples=examples, title="๐Ÿ—ฟ PerfectGPT v1 ๐Ÿ—ฟ", description=description)
53
 
54
  PerfectGPT.launch()
 
9
  model = AutoModelForSeq2SeqLM.from_pretrained(
10
  "Kaludi/chatgpt-gpt4-prompts-bart-large-cnn-samsum", from_tf=True)
11
 
12
+ # zephyr
13
+ pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-alpha",torch_dtype=torch.bfloat16, device_map="auto")
14
 
15
+ def generate(inputuno, inputdos, max_new_tokens=3556, top_p=0.95, repetition_penalty=1.0):
16
+ top_p = float(top_p)
17
 
18
+ prompt = inputuno
19
+ promptdos = inputdos
20
+
21
+ generate_kwargs = dict(
22
+ temperature=fixed_temperature,
23
+ max_new_tokens=max_new_tokens,
24
+ top_p=top_p,
25
+ repetition_penalty=repetition_penalty,
26
+ do_sample=True,
27
+ seed=42,
28
+ )
29
+
30
+ messages = [
31
+ {
32
+ "role": "system", "content": str(new_prompt)
33
+ },
34
+ {
35
+ "role": "user", "content": str(promptdos)
36
+ },
37
+ ]
38
+
39
+ stream = pipe.tokenizer.apply_chat_template(messages, **generate_kwargs, stream=True, details=True, return_full_text=False)
40
+ output = ""
41
+
42
+ for response in stream:
43
+ output += response.token.text
44
+ yield output
45
+ return output
46
+
47
+
48
+ def generatePrompt(inputuno, inputdos):
49
 
50
  prompt = inputuno
51
  promptdos = inputdos
 
81
  "human resources staff"], ["recipe for ham croquettes"]]
82
  description = ""
83
 
84
+ PerfectGPT = gr.Interface(generate, inputs=[input_prompt, input_promptdos], outputs=output_component, examples=examples, title="๐Ÿ—ฟ PerfectGPT v1 ๐Ÿ—ฟ", description=description)
85
 
86
  PerfectGPT.launch()