fix copy bug
This commit is contained in:
@@ -26,7 +26,8 @@ class XmlLogitsProcessor(LogitsProcessor):
|
||||
items = dict()
|
||||
for token, id in vocab.items():
|
||||
items[id] = token
|
||||
self.core = XmlLogitsProcessorCore(items, schema_text)
|
||||
if schema_text:
|
||||
self.core = XmlLogitsProcessorCore(items, schema_text)
|
||||
self.prompt_length = None
|
||||
self.is_first_call = True
|
||||
|
||||
@@ -72,4 +73,18 @@ class XmlLogitsProcessor(LogitsProcessor):
|
||||
if token < scores.shape[1]:
|
||||
scores[batch_idx, token] = float('-inf')
|
||||
|
||||
return scores
|
||||
return scores
|
||||
|
||||
def copy(self):
|
||||
"""
|
||||
Create a copy of the processor.
|
||||
|
||||
Returns:
|
||||
A new instance of the processor
|
||||
"""
|
||||
cloned = XmlLogitsProcessor(self.tokenizer, None)
|
||||
cloned.eos_token_id = self.eos_token_id
|
||||
cloned.core = self.core.copy()
|
||||
cloned.prompt_length = self.prompt_length
|
||||
cloned.is_first_call = self.is_first_call
|
||||
return cloned
|
||||
Reference in New Issue
Block a user