wiklif commited on
Commit
e3675c5
·
1 Parent(s): 6f67e5a

fix </s> v2

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -10,19 +10,21 @@ def generate_response(chat, kwargs):
10
  stream = client.text_generation(chat, **kwargs, stream=True, details=True, return_full_text=False)
11
  for response in stream:
12
  output += response.token.text
 
 
13
  return output
14
 
15
- def function(prompt, history=[]): # Tutaj dodajemy history jako opcjonalny parametr
16
  chat = "<s>"
17
  for user_prompt, bot_response in history:
18
  chat += f"[INST] {user_prompt} [/INST] {bot_response}</s> <s>"
19
- chat += f"[INST] {prompt} [/INST]"
20
  kwargs = dict(
21
- temperature=0.80,
22
- max_new_tokens=2048,
23
  top_p=0.95,
24
  repetition_penalty=1.0,
25
- do_sample=True, # Upewnij się, że używasz próbkowania
26
  seed=1337
27
  )
28
 
@@ -53,5 +55,4 @@ interface = gr.ChatInterface(
53
  clear_btn=None
54
  )
55
 
56
- # Ustawienie share=True pozwala na stworzenie publicznego linku do aplikacji
57
  interface.launch(show_api=True, share=True)
 
10
  stream = client.text_generation(chat, **kwargs, stream=True, details=True, return_full_text=False)
11
  for response in stream:
12
  output += response.token.text
13
+ if output.endswith("</s>"): # Sprawdzamy, czy odpowiedź kończy się tagiem </s>
14
+ output = output[:-4] # Usuwamy tag </s> z końca odpowiedzi
15
  return output
16
 
17
+ def function(prompt, history=[]):
18
  chat = "<s>"
19
  for user_prompt, bot_response in history:
20
  chat += f"[INST] {user_prompt} [/INST] {bot_response}</s> <s>"
21
+ chat += f"[INST] {prompt} [/INST]" # Zostawiamy tylko tag otwierający <s> na początku i kończymy ciąg zwykłym znacznikiem
22
  kwargs = dict(
23
+ temperature=0.5,
24
+ max_new_tokens=4096,
25
  top_p=0.95,
26
  repetition_penalty=1.0,
27
+ do_sample=True,
28
  seed=1337
29
  )
30
 
 
55
  clear_btn=None
56
  )
57
 
 
58
  interface.launch(show_api=True, share=True)