Views
No views yet

<|prompt|>prompt<|endoftext|>
<|answer|>git clone https://github.com/cmp-nct/ggllm.cpp
cd ggllm.cpp
rm -rf build && mkdir build && cd build && cmake -DGGML_CUBLAS=1 .. && cmake --build . --config Releasebin/falcon_main just like you would use llama.cpp. For example:bin/falcon_main -t 8 -ngl 100 -b 1 -m h2ogpt-falcon-40b.ggmlv3.q3_k.bin -p "What is a falcon?\n### Response:"-ngl 100 regardles of your VRAM, as it will automatically detect how much VRAM is available to be used.-t 8 (the number of CPU cores to use) according to what performs best on your system. Do not exceed the number of physical CPU cores you have.-b 1 reduces batch size to 1. This slightly lowers prompt evaluation time, but frees up VRAM to load more of the model on to your GPU. If you find prompt evaluation too slow and have enough spare VRAM, you can remove this parameter.| Name | Quant method | Bits | Size | Max RAM required | Use case |
|---|---|---|---|---|---|
| h2ogpt-falcon-40b.ggmlv3.q2_k.bin | q2_k | 2 | 13.74 GB | 16.24 GB | New k-quant method. Uses GGML_TYPE_Q5_K for the attention.vw and feed_forward.w2 tensors, GGML_TYPE_Q2_K for the other tensors. |
| h2ogpt-falcon-40b.ggmlv3.q3_k.bin | q3_k | 3 | 17.98 GB | 20.48 GB | New k-quant method. Uses GGML_TYPE_Q3_K for all tensors |
| h2ogpt-falcon-40b.ggmlv3.q4_0.bin | q4_0 | 4 | 23.54 GB | 26.04 GB | Old quant method, 4-bit. |
| h2ogpt-falcon-40b.ggmlv3.q4_1.bin | q4_1 | 4 | 26.16 GB | 28.66 GB | Old quant method, 4-bit. Higher accuracy than q4_0 but not as high as q5_0. However has quicker inference than q5 models. |
| h2ogpt-falcon-40b.ggmlv3.q4_k.bin | q4_k | 4 | 23.54 GB | 26.04 GB | New k-quant method. Uses GGML_TYPE_Q4_K for all tensors |
| h2ogpt-falcon-40b.ggmlv3.q5_0.bin | q5_0 | 5 | 28.77 GB | 31.27 GB | Old quant method, 5-bit. Higher accuracy, higher resource usage and slower inference. |
| h2ogpt-falcon-40b.ggmlv3.q5_1.bin | q5_1 | 5 | 31.38 GB | 33.88 GB | Old quant method, 5-bit. Even higher accuracy, resource usage and slower inference. |
| h2ogpt-falcon-40b.ggmlv3.q5_k.bin | q5_k | 5 | 28.77 GB | 31.27 GB | New k-quant method. Uses GGML_TYPE_Q5_K for all tensors |
| h2ogpt-falcon-40b.ggmlv3.q6_k.bin | q6_k | 6 | 34.33 GB | 36.83 GB | New k-quant method. Uses GGML_TYPE_Q8_K - 6-bit quantization - for all tensors |
| h2ogpt-falcon-40b.ggmlv3.q8_0.bin | q8_0 | 8 | 44.46 GB | 46.96 GB | Old quant method, 8-bit. Almost indistinguishable from float16. High resource use and slow. Not recommended for most users. |
transformers library on a machine with GPUs, first make sure you have the transformers, accelerate and torch libraries installed.1pip install transformers==4.29.2
2pip install bitsandbytes==0.39.0
3pip install accelerate==0.19.0
4pip install torch==2.0.0
5pip install einops==0.6.11import torch
2from transformers import pipeline, BitsAndBytesConfig, AutoTokenizer
3
4model_kwargs = {}
5
6quantization_config = None
7# optional quantization
8quantization_config = BitsAndBytesConfig(
9 load_in_8bit=True,
10 llm_int8_threshold=6.0,
11)
12model_kwargs["quantization_config"] = quantization_config
13
14tokenizer = AutoTokenizer.from_pretrained(
15 "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
16 use_fast=False,
17 padding_side="left",
18 trust_remote_code=True,
19)
20
21generate_text = pipeline(
22 model="h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
23 tokenizer=tokenizer,
24 torch_dtype=torch.float16,
25 trust_remote_code=True,
26 use_fast=False,
27 device_map={"": "cuda:0"},
28 model_kwargs=model_kwargs,
29)
30
31res = generate_text(
32 "Why is drinking water so healthy?",
33 min_new_tokens=2,
34 max_new_tokens=1024,
35 do_sample=False,
36 num_beams=1,
37 temperature=float(0.3),
38 repetition_penalty=float(1.2),
39 renormalize_logits=True
40)
41print(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, BitsAndBytesConfig
4
5quantization_config = None
6# optional quantization
7quantization_config = BitsAndBytesConfig(
8 load_in_8bit=True,
9 llm_int8_threshold=6.0,
10)
11
12tokenizer = AutoTokenizer.from_pretrained(
13 "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
14 use_fast=False,
15 padding_side="left",
16 trust_remote_code=True,
17)
18model = AutoModelForCausalLM.from_pretrained(
19 "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
20 trust_remote_code=True,
21 torch_dtype=torch.float16,
22 device_map={"": "cuda:0"},
23 quantization_config=quantization_config
24).eval()
25generate_text = H2OTextGenerationPipeline(model=model, tokenizer=tokenizer)
26
27res = generate_text(
28 "Why is drinking water so healthy?",
29 min_new_tokens=2,
30 max_new_tokens=1024,
31 do_sample=False,
32 num_beams=1,
33 temperature=float(0.3),
34 repetition_penalty=float(1.2),
35 renormalize_logits=True
36)
37print(res[0]["generated_text"])1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
2
3# Important: The prompt needs to be in the same format the model was trained with.
4# You can find an example prompt in the experiment logs.
5prompt = "<|prompt|>How are you?<|endoftext|><|answer|>"
6
7quantization_config = None
8# optional quantization
9quantization_config = BitsAndBytesConfig(
10 load_in_8bit=True,
11 llm_int8_threshold=6.0,
12)
13
14tokenizer = AutoTokenizer.from_pretrained(
15 "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
16 use_fast=False,
17 padding_side="left",
18 trust_remote_code=True,
19)
20model = AutoModelForCausalLM.from_pretrained(
21 "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
22 trust_remote_code=True,
23 torch_dtype=torch.float16,
24 device_map={"": "cuda:0"},
25 quantization_config=quantization_config
26).eval()
27
28inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
29
30# generate configuration can be modified to your needs
31tokens = model.generate(
32 **inputs,
33 min_new_tokens=2,
34 max_new_tokens=1024,
35 do_sample=False,
36 num_beams=1,
37 temperature=float(0.3),
38 repetition_penalty=float(1.2),
39 renormalize_logits=True
40)[0]
41
42tokens = tokens[inputs["input_ids"].shape[1]:]
43answer = tokenizer.decode(tokens, skip_special_tokens=True)
44print(answer)RWForCausalLM(
(transformer): RWModel(
(word_embeddings): Embedding(65024, 8192)
(h): ModuleList(
(0-59): 60 x DecoderLayer(
(ln_attn): LayerNorm((8192,), eps=1e-05, elementwise_affine=True)
(ln_mlp): LayerNorm((8192,), eps=1e-05, elementwise_affine=True)
(self_attention): Attention(
(maybe_rotary): RotaryEmbedding()
(query_key_value): Linear(in_features=8192, out_features=9216, bias=False)
(dense): Linear(in_features=8192, out_features=8192, bias=False)
(attention_dropout): Dropout(p=0.0, inplace=False)
)
(mlp): MLP(
(dense_h_to_4h): Linear(in_features=8192, out_features=32768, bias=False)
(act): GELU(approximate='none')
(dense_4h_to_h): Linear(in_features=32768, out_features=8192, bias=False)
)
)
)
(ln_f): LayerNorm((8192,), eps=1e-05, elementwise_affine=True)
)
(lm_head): Linear(in_features=8192, out_features=65024, bias=False)
)