Fix repeating instructions and an antiprompt bug
This commit is contained in:
parent
9cde7973cc
commit
c862e8bac5
1 changed files with 7 additions and 5 deletions
|
@ -75,7 +75,7 @@ class LLaMAInteract:
|
||||||
|
|
||||||
# add instruction as antiprompt
|
# add instruction as antiprompt
|
||||||
if (self.instruct):
|
if (self.instruct):
|
||||||
self.first_antiprompt.append(self._tokenize(self.inp_prefix.strip()))
|
self.first_antiprompt.append(self._tokenize(instruct_inp_prefix.strip(), False))
|
||||||
|
|
||||||
# primer feed
|
# primer feed
|
||||||
if (len(primer) > 0):
|
if (len(primer) > 0):
|
||||||
|
@ -197,7 +197,8 @@ class LLaMAInteract:
|
||||||
|
|
||||||
# respect n_predict even if antiprompt is present
|
# respect n_predict even if antiprompt is present
|
||||||
if (self.use_antiprompt() and self.remaining_tokens <= 0 and self.n_predict != -1):
|
if (self.use_antiprompt() and self.remaining_tokens <= 0 and self.n_predict != -1):
|
||||||
self.embd_inp += self.first_antiprompt[0]
|
if not self.instruct:
|
||||||
|
self.embd_inp += self.first_antiprompt[0]
|
||||||
break
|
break
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
|
@ -213,7 +214,7 @@ class LLaMAInteract:
|
||||||
|
|
||||||
# write input
|
# write input
|
||||||
def input(self, prompt: str):
|
def input(self, prompt: str):
|
||||||
if (self.instruct):
|
if (self.instruct and self.last_n_tokens[-len(self.inp_prefix):] != self.inp_prefix):
|
||||||
self.embd_inp += self.inp_prefix
|
self.embd_inp += self.inp_prefix
|
||||||
self.embd_inp += self._tokenize(prompt)
|
self.embd_inp += self._tokenize(prompt)
|
||||||
if (self.instruct):
|
if (self.instruct):
|
||||||
|
@ -284,5 +285,6 @@ The transcript only includes text, it does not include markup like HTML and Mark
|
||||||
for i in m.output():
|
for i in m.output():
|
||||||
print(i,end="",flush=True)
|
print(i,end="",flush=True)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print(f"\n{USER_NAME}:",end="")
|
if not m.instruct:
|
||||||
m.input(f"\n{USER_NAME}:")
|
print(f"\n{USER_NAME}:",end="")
|
||||||
|
m.input(f"\n{USER_NAME}:")
|
||||||
|
|
Loading…
Reference in a new issue