Views
No views yet
1
2from exllamav2 import ExLlamaV2, ExLlamaV2Config, ExLlamaV2Cache, ExLlamaV2Tokenizer
3from exllamav2.generator import ExLlamaV2Sampler, ExLlamaV2DynamicGenerator
4
5model_path = /path/to/model_folder
6
7config = ExLlamaV2Config(model_path)
8model = ExLlamaV2(config)
9cache = ExLlamaV2Cache(model, max_seq_len = 4096, lazy = True)
10model.load_autosplit(cache, progress = True)
11tokenizer = ExLlamaV2Tokenizer(config)
12
13generator = ExLlamaV2DynamicGenerator(
14 model = model,
15 cache = cache,
16 tokenizer = tokenizer,
17)
18
19
20
21gen_settings = ExLlamaV2Sampler.Settings(
22 temperature = 1.0,
23 top_p = 0.1,
24 token_repetition_penalty = 1.0
25)
26
27outputs = generator.generate(
28 prompt = ["first input", "second input"], # string or list of strings
29 max_new_tokens = 1024,
30 stop_conditions = [tokenizer.eos_token_id],
31 gen_settings = gen_settings,
32 add_bos = True,
33)
34
35print(outputs)
36