Views
No views yet

1def tokenize_single_input(tokenizer, prompt):
2 # OpenChat V2
3 human_prefix = "User:"
4 prefix = "Assistant GPT4:"
5 eot_token = "<|end_of_turn|>"
6 bos_token = "<s>"
7
8 def _tokenize(text):
9 return tokenizer.convert_tokens_to_ids(tokenizer._tokenize(text))
10
11 def _tokenize_special(special_name):
12 return tokenizer.convert_tokens_to_ids(special_name)
13
14 return [_tokenize_special(bos_token)] + _tokenize(human_prefix) + _tokenize(prompt) + [_tokenize_special(eot_token)] + \
15 _tokenize(prefix)| Branch | Bits | Group Size | Act Order (desc_act) | File Size | ExLlama Compatible? | Made With | Description |
|---|---|---|---|---|---|---|---|
| main | 4 | 128 | False | 7.45 GB | True | GPTQ-for-LLaMa | 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 | 8.00 GB | True | 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_False | 4 | 64 | False | 7.51 GB | True | AutoGPTQ | 4-bit, without Act Order and group size. Without Act Order to improve AutoGPTQ speed, and better accuracy than 128g-False. |
| gptq-4bit-64g-actorder_True | 4 | 64 | True | 7.51 GB | True | 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 | 7.26 GB | True | 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 | 13.36 GB | False | AutoGPTQ | 8-bit, with Act Order. No group size, to lower VRAM requirements and to improve AutoGPTQ speed. |
| gptq-8bit-128g-actorder_True | 8 | 128 | True | 13.65 GB | False | AutoGPTQ | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. Poor AutoGPTQ CUDA speed. |
| gptq-8bit-128g-actorder_False | 8 | 128 | False | 13.65 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/openchat_v2_openorca_preview-GPTQ:gptq-4bit-32g-actorder_Truegit clone --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/openchat_v2_openorca_preview-GPTQ`revision parameter; see below.TheBloke/openchat_v2_openorca_preview-GPTQ.TheBloke/openchat_v2_openorca_preview-GPTQ:gptq-4bit-32g-actorder_Trueopenchat_v2_openorca_preview-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/openchat_v2_openorca_preview-GPTQ"
5model_basename = "openorca-openchat-v2-preview2-GPTQ-4bit-128g.no-act.order"
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"
32
33def tokenize_single_input(tokenizer, prompt):
34 # OpenChat V2
35 human_prefix = "User:"
36 prefix = "Assistant GPT4:"
37 eot_token = "<|end_of_turn|>"
38 bos_token = "<s>"
39
40 def _tokenize(text):
41 return tokenizer.convert_tokens_to_ids(tokenizer._tokenize(text))
42
43 def _tokenize_special(special_name):
44 return tokenizer.convert_tokens_to_ids(special_name)
45
46 return [_tokenize_special(bos_token)] + _tokenize(human_prefix) + _tokenize(prompt) + [_tokenize_special(eot_token)] + \
47 _tokenize(prefix)
48
49print("\n\n*** Generate:")
50
51input_ids = tokenizer_single_input(tokenizer, prompt)
52output = model.generate(inputs=input_ids, temperature=0.7, max_new_tokens=512)
53print(tokenizer.decode(output[0]))

OpenChat V2 OpenOrca Preview
name accuracy unmatched
aqua-rat.zero-shot 0.232283 0.0
logiqa-en.zero-shot 0.370200 0.0
lsat-ar.zero-shot 0.230435 0.0
lsat-lr.zero-shot 0.441176 0.0
lsat-rc.zero-shot 0.568773 0.0
sat-en-without-passage.zero-shot 0.393204 0.0
sat-en.zero-shot 0.747573 0.0
sat-math.zero-shot 0.295455 0.0
Average 0.409887 0.0
AGIEval Average reported in Orca paper: 0.417python -m ochat.serving.openai_api_server --model_type openchat_v2 --model openchat/openchat_v2_openorca_preview --engine-use-ray --worker-use-ray<|end_of_turn|> is added.1def tokenize_single_input(tokenizer, prompt):
2 # OpenChat V2
3 human_prefix = "User:"
4 prefix = "Assistant GPT4:"
5 eot_token = "<|end_of_turn|>"
6 bos_token = "<s>"
7
8 def _tokenize(text):
9 return tokenizer.convert_tokens_to_ids(tokenizer._tokenize(text))
10
11 def _tokenize_special(special_name):
12 return tokenizer.convert_tokens_to_ids(special_name)
13
14 return [_tokenize_special(bos_token)] + _tokenize(human_prefix) + _tokenize(prompt) + [_tokenize_special(eot_token)] + \
15 _tokenize(prefix)prefix = "Assistant GPT3:" to mimic ChatGPT behavior (this may cause performance degradation).tokenize(A) + tokenize(B) does not always equals to tokenize(A + B)