3v324v23 commited on
Commit
c37c49d
1 Parent(s): a15489d

lazy load +decode 方法

Browse files
Files changed (1) hide show
  1. request_llm/bridge_all.py +5 -1
request_llm/bridge_all.py CHANGED
@@ -38,7 +38,11 @@ class LazyloadTiktoken(object):
38
  def encode(self, *args, **kwargs):
39
  encoder = self.get_encoder(self.model)
40
  return encoder.encode(*args, **kwargs)
41
-
 
 
 
 
42
  tokenizer_gpt35 = LazyloadTiktoken("gpt-3.5-turbo")
43
  tokenizer_gpt4 = LazyloadTiktoken("gpt-4")
44
  get_token_num_gpt35 = lambda txt: len(tokenizer_gpt35.encode(txt, disallowed_special=()))
 
38
  def encode(self, *args, **kwargs):
39
  encoder = self.get_encoder(self.model)
40
  return encoder.encode(*args, **kwargs)
41
+
42
+ def decode(self, *args, **kwargs):
43
+ encoder = self.get_encoder(self.model)
44
+ return encoder.decode(*args, **kwargs)
45
+
46
  tokenizer_gpt35 = LazyloadTiktoken("gpt-3.5-turbo")
47
  tokenizer_gpt4 = LazyloadTiktoken("gpt-4")
48
  get_token_num_gpt35 = lambda txt: len(tokenizer_gpt35.encode(txt, disallowed_special=()))