Views
No views yet

<|prompt|>{prompt}<|endoftext|><|answer|>| Branch | Bits | Group Size | Act Order (desc_act) | File Size | ExLlama Compatible? | Made With | Description |
|---|---|---|---|---|---|---|---|
| main | 4 | 128 | False | 4.63 GB | False | AutoGPTQ | Most compatible option. Good inference speed in AutoGPTQ and GPTQ-for-LLaMa. Lower inference quality than other options. |
| gptq-4bit-32g-actorder_True | 4 | 32 | True | 5.02 GB | False | AutoGPTQ | 4-bit, with Act Order and group size. 32g gives highest possible inference quality, with maximum VRAM usage. Poor AutoGPTQ CUDA speed. |
| gptq-4bit-64g-actorder_True | 4 | 64 | True | 4.76 GB | False | AutoGPTQ | 4-bit, with Act Order and group size. 64g uses less VRAM than 32g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
| gptq-4bit-128g-actorder_True | 4 | 128 | True | 4.63 GB | False | AutoGPTQ | 4-bit, with Act Order and group size. 128g uses even less VRAM, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
| gptq-8bit--1g-actorder_True | 8 | None | True | 7.82 GB | False | AutoGPTQ | 8-bit, with Act Order. No group size, to lower VRAM requirements and to improve AutoGPTQ speed. |
| gptq-8bit-128g-actorder_False | 8 | 128 | False | 7.97 GB | False | AutoGPTQ | 8-bit, with group size 128g for higher inference quality and without Act Order to improve AutoGPTQ speed. |
:branch to the end of the download name, eg TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ:gptq-4bit-32g-actorder_Truegit clone --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ`revision parameter; see below.TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ.TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ:gptq-4bit-32g-actorder_Trueh2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQquantize_config.json.GITHUB_ACTIONS=true pip install auto-gptq1from transformers import AutoTokenizer, pipeline, logging
2from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
3
4model_name_or_path = "TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ"
5model_basename = "model"
6
7use_triton = False
8
9tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
10
11model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
12 model_basename=model_basename,
13 use_safetensors=True,
14 trust_remote_code=True,
15 device="cuda:0",
16 use_triton=use_triton,
17 quantize_config=None)
18
19"""
20To download from a specific branch, use the revision parameter, as in this example:
21
22model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
23 revision="gptq-4bit-32g-actorder_True",
24 model_basename=model_basename,
25 use_safetensors=True,
26 trust_remote_code=True,
27 device="cuda:0",
28 quantize_config=None)
29"""
30
31prompt = "Tell me about AI"
32prompt_template=f'''<|prompt|>{prompt}<|endoftext|><|answer|>
33'''
34
35print("\n\n*** Generate:")
36
37input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
38output = model.generate(inputs=input_ids, temperature=0.7, max_new_tokens=512)
39print(tokenizer.decode(output[0]))
40
41# Inference can also be done using transformers' pipeline
42
43# Prevent printing spurious transformers error when using pipeline with AutoGPTQ
44logging.set_verbosity(logging.CRITICAL)
45
46print("*** Pipeline:")
47pipe = pipeline(
48 "text-generation",
49 model=model,
50 tokenizer=tokenizer,
51 max_new_tokens=512,
52 temperature=0.7,
53 top_p=0.95,
54 repetition_penalty=1.15
55)
56
57print(pipe(prompt_template)[0]['generated_text'])transformers library on a machine with GPUs, first make sure you have the transformers, accelerate, torch and einops libraries installed.1pip install transformers==4.29.2
2pip install accelerate==0.19.0
3pip install torch==2.0.0
4pip install einops==0.6.11import torch
2from transformers import AutoTokenizer, pipeline
3
4
5tokenizer = AutoTokenizer.from_pretrained(
6 "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3",
7 use_fast=False,
8 padding_side="left",
9 trust_remote_code=True,
10)
11
12generate_text = pipeline(
13 model="h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3",
14 tokenizer=tokenizer,
15 torch_dtype=torch.float16,
16 trust_remote_code=True,
17 use_fast=False,
18 device_map={"": "cuda:0"},
19)
20
21res = generate_text(
22 "Why is drinking water so healthy?",
23 min_new_tokens=2,
24 max_new_tokens=1024,
25 do_sample=False,
26 num_beams=1,
27 temperature=float(0.3),
28 repetition_penalty=float(1.2),
29 renormalize_logits=True
30)
31print(res[0]["generated_text"])print(generate_text.preprocess("Why is drinking water so healthy?")["prompt_text"])<|prompt|>Why is drinking water so healthy?<|endoftext|><|answer|>1import torch
2from h2oai_pipeline import H2OTextGenerationPipeline
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5tokenizer = AutoTokenizer.from_pretrained(
6 "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3",
7 use_fast=False,
8 padding_side="left",
9 trust_remote_code=True,
10)
11model = AutoModelForCausalLM.from_pretrained(
12 "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3",
13 torch_dtype=torch.float16,
14 device_map={"": "cuda:0"},
15 trust_remote_code=True,
16)
17generate_text = H2OTextGenerationPipeline(model=model, tokenizer=tokenizer)
18
19res = generate_text(
20 "Why is drinking water so healthy?",
21 min_new_tokens=2,
22 max_new_tokens=1024,
23 do_sample=False,
24 num_beams=1,
25 temperature=float(0.3),
26 repetition_penalty=float(1.2),
27 renormalize_logits=True
28)
29print(res[0]["generated_text"])1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3" # either local folder or huggingface model name
4# Important: The prompt needs to be in the same format the model was trained with.
5# You can find an example prompt in the experiment logs.
6prompt = "<|prompt|>How are you?<|endoftext|><|answer|>"
7
8tokenizer = AutoTokenizer.from_pretrained(
9 model_name,
10 use_fast=False,
11 trust_remote_code=True,
12)
13model = AutoModelForCausalLM.from_pretrained(
14 model_name,
15 torch_dtype=torch.float16,
16 device_map={"": "cuda:0"},
17 trust_remote_code=True,
18)
19model.cuda().eval()
20inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
21
22# generate configuration can be modified to your needs
23tokens = model.generate(
24 **inputs,
25 min_new_tokens=2,
26 max_new_tokens=1024,
27 do_sample=False,
28 num_beams=1,
29 temperature=float(0.3),
30 repetition_penalty=float(1.2),
31 renormalize_logits=True
32)[0]
33
34tokens = tokens[inputs["input_ids"].shape[1]:]
35answer = tokenizer.decode(tokens, skip_special_tokens=True)
36print(answer)RWForCausalLM(
(transformer): RWModel(
(word_embeddings): Embedding(65024, 4544)
(h): ModuleList(
(0-31): 32 x DecoderLayer(
(input_layernorm): LayerNorm((4544,), eps=1e-05, elementwise_affine=True)
(self_attention): Attention(
(maybe_rotary): RotaryEmbedding()
(query_key_value): Linear(in_features=4544, out_features=4672, bias=False)
(dense): Linear(in_features=4544, out_features=4544, bias=False)
(attention_dropout): Dropout(p=0.0, inplace=False)
)
(mlp): MLP(
(dense_h_to_4h): Linear(in_features=4544, out_features=18176, bias=False)
(act): GELU(approximate='none')
(dense_4h_to_h): Linear(in_features=18176, out_features=4544, bias=False)
)
)
)
(ln_f): LayerNorm((4544,), eps=1e-05, elementwise_affine=True)
)
(lm_head): Linear(in_features=4544, out_features=65024, bias=False)
)