Add autosplit, temperature_last
This commit is contained in:
+23
-13
@@ -34,6 +34,7 @@ class Loader:
|
|||||||
self.generator = None
|
self.generator = None
|
||||||
self.gpu_split = None
|
self.gpu_split = None
|
||||||
self.cache_8bit = False
|
self.cache_8bit = False
|
||||||
|
self.cache_lazy = False
|
||||||
|
|
||||||
def process(self, model_dir, gpu_split, cache_8bit, max_seq_len):
|
def process(self, model_dir, gpu_split, cache_8bit, max_seq_len):
|
||||||
self.unload()
|
self.unload()
|
||||||
@@ -41,7 +42,9 @@ class Loader:
|
|||||||
self.config.model_dir = model_dir
|
self.config.model_dir = model_dir
|
||||||
self.config.prepare()
|
self.config.prepare()
|
||||||
|
|
||||||
if gpu_split:
|
if gpu_split == "auto":
|
||||||
|
self.cache_lazy = True
|
||||||
|
elif gpu_split:
|
||||||
self.gpu_split = [float(a) for a in gpu_split.split(",")]
|
self.gpu_split = [float(a) for a in gpu_split.split(",")]
|
||||||
|
|
||||||
if max_seq_len:
|
if max_seq_len:
|
||||||
@@ -57,12 +60,16 @@ class Loader:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.base = ExLlamaV2(self.config)
|
self.base = ExLlamaV2(self.config)
|
||||||
self.base.load(gpu_split=self.gpu_split)
|
|
||||||
|
|
||||||
if self.cache_8bit:
|
if self.cache_8bit:
|
||||||
self.cache = ExLlamaV2Cache_8bit(self.base)
|
self.cache = ExLlamaV2Cache_8bit(self.base, lazy=self.cache_lazy)
|
||||||
else:
|
else:
|
||||||
self.cache = ExLlamaV2Cache(self.base)
|
self.cache = ExLlamaV2Cache(self.base, lazy=self.cache_lazy)
|
||||||
|
|
||||||
|
if self.cache_lazy:
|
||||||
|
self.base.load_autosplit(self.cache)
|
||||||
|
else:
|
||||||
|
self.base.load(gpu_split=self.gpu_split)
|
||||||
|
|
||||||
self.tokenizer = ExLlamaV2Tokenizer(self.config)
|
self.tokenizer = ExLlamaV2Tokenizer(self.config)
|
||||||
self.generator = ExLlamaV2StreamingGenerator(self.base, self.cache, self.tokenizer)
|
self.generator = ExLlamaV2StreamingGenerator(self.base, self.cache, self.tokenizer)
|
||||||
@@ -87,11 +94,12 @@ class Generator:
|
|||||||
"single_line": ("BOOLEAN", {"default": False}),
|
"single_line": ("BOOLEAN", {"default": False}),
|
||||||
"max_tokens": ("INT", {"default": 128, "max": 2**16}),
|
"max_tokens": ("INT", {"default": 128, "max": 2**16}),
|
||||||
"temperature": ("FLOAT", {"default": 1, "max": 2, "step": 0.01}),
|
"temperature": ("FLOAT", {"default": 1, "max": 2, "step": 0.01}),
|
||||||
|
"temperature_last": ("BOOLEAN", {"default": True}),
|
||||||
"min_p": ("FLOAT", {"default": 0.1, "max": 1, "step": 0.01}),
|
"min_p": ("FLOAT", {"default": 0.1, "max": 1, "step": 0.01}),
|
||||||
"top_k": ("INT", {"max": 200}),
|
|
||||||
"top_p": ("FLOAT", {"default": 1, "max": 1, "step": 0.01}),
|
"top_p": ("FLOAT", {"default": 1, "max": 1, "step": 0.01}),
|
||||||
"typical": ("FLOAT", {"default": 1, "max": 1, "step": 0.01}),
|
"typical_p": ("FLOAT", {"default": 1, "max": 1, "step": 0.01}),
|
||||||
"penalty": ("FLOAT", {"default": 1, "min": 1, "max": 2, "step": 0.01}),
|
"top_k": ("INT", {"max": 200}),
|
||||||
|
"rep_penalty": ("FLOAT", {"default": 1, "min": 1, "max": 2, "step": 0.01}),
|
||||||
"seed": ("INT", {"max": 2**64 - 1}),
|
"seed": ("INT", {"max": 2**64 - 1}),
|
||||||
"text": ("STRING", {"multiline": True}),
|
"text": ("STRING", {"multiline": True}),
|
||||||
},
|
},
|
||||||
@@ -113,11 +121,12 @@ class Generator:
|
|||||||
single_line,
|
single_line,
|
||||||
max_tokens,
|
max_tokens,
|
||||||
temperature,
|
temperature,
|
||||||
|
temperature_last,
|
||||||
min_p,
|
min_p,
|
||||||
top_k,
|
|
||||||
top_p,
|
top_p,
|
||||||
typical,
|
typical_p,
|
||||||
penalty,
|
top_k,
|
||||||
|
rep_penalty,
|
||||||
seed,
|
seed,
|
||||||
text,
|
text,
|
||||||
info=None,
|
info=None,
|
||||||
@@ -144,11 +153,12 @@ class Generator:
|
|||||||
|
|
||||||
settings = ExLlamaV2Sampler.Settings()
|
settings = ExLlamaV2Sampler.Settings()
|
||||||
settings.temperature = temperature
|
settings.temperature = temperature
|
||||||
|
settings.temperature_last = temperature_last
|
||||||
settings.min_p = min_p
|
settings.min_p = min_p
|
||||||
settings.top_k = top_k
|
|
||||||
settings.top_p = top_p
|
settings.top_p = top_p
|
||||||
settings.typical = typical
|
settings.typical = typical_p
|
||||||
settings.token_repetition_penalty = penalty
|
settings.top_k = top_k
|
||||||
|
settings.token_repetition_penalty = rep_penalty
|
||||||
|
|
||||||
model.generator.begin_stream(input, settings, token_healing=True)
|
model.generator.begin_stream(input, settings, token_healing=True)
|
||||||
progress = ProgressBar(max_tokens)
|
progress = ProgressBar(max_tokens)
|
||||||
|
|||||||
Reference in New Issue
Block a user