Views
No views yet

| Models | Llama2-7B (fp16) | Llama2-7B (HQQ 1-bit) | Llama2-7B (HQQ+ 1-bit) | Quip# (2-bit) |
|---|---|---|---|---|
| Wiki Perpexlity | 5.18 | 9866 | 8.53 | 8.54 |
| VRAM (GB) | 13.5 | 1.76 | 1.85 | 2.72 |
| forward time (sec) | 0.1 | 0.231 | 0.257 | 0.353 |
| Models | Llama2-7B-chat (fp16) | Llama2-7B-chat (HQQ 1-bit) | Llama2-7B-chat (HQQ+ 1-bit) |
|---|---|---|---|
| ARC (25-shot) | 53.67 | 21.59 | 31.14 |
| HellaSwag (10-shot) | 78.56 | 25.66 | 52.96 |
| MMLU (5-shot) | 48.16 | 25.08 | 26.54 |
| TruthfulQA-MC2 | 45.32 | 47.81 | 43.16 |
| Winogrande (5-shot) | 72.53 | 49.72 | 60.54 |
| GSM8K (5-shot) | 23.12 | 0 | 11 |
| Average | 53.56 | 28.31 | 37.56 |
#This model is deprecated and requires older versions
pip install hqq==0.1.8
pip install transformers==4.401from hqq.engine.hf import HQQModelForCausalLM, AutoTokenizer
2
3#Load the model
4model_id = 'mobiuslabsgmbh/Llama-2-7b-chat-hf_1bitgs8_hqq'
5model = HQQModelForCausalLM.from_quantized(model_id, adapter='adapter_v0.1.lora')
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7
8#Setup Inference Mode
9tokenizer.add_bos_token = False
10tokenizer.add_eos_token = False
11if not tokenizer.pad_token: tokenizer.add_special_tokens({'pad_token': '[PAD]'})
12model.config.use_cache = True
13model.eval();
14
15# Optional: torch compile for faster inference
16# model = torch.compile(model)
17
18#Streaming Inference
19import torch, transformers
20from threading import Thread
21
22def chat_processor(chat, max_new_tokens=100, do_sample=True, device='cuda'):
23 tokenizer.use_default_system_prompt = False
24 streamer = transformers.TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
25
26 generate_params = dict(
27 tokenizer("<s> [INST] " + chat + " [/INST] ", return_tensors="pt").to(device),
28 streamer=streamer,
29 max_new_tokens=max_new_tokens,
30 do_sample=do_sample,
31 pad_token_id=tokenizer.pad_token_id,
32 top_p=0.90 if do_sample else None,
33 top_k=50 if do_sample else None,
34 temperature= 0.6 if do_sample else None,
35 num_beams=1,
36 repetition_penalty=1.2,
37 )
38
39 t = Thread(target=model.generate, kwargs=generate_params)
40 t.start()
41
42 print("User: ", chat);
43 print("Assistant: ");
44 outputs = ""
45 for text in streamer:
46 outputs += text
47 print(text, end="", flush=True)
48
49 torch.cuda.empty_cache()
50
51 return outputsoutputs = chat_processor("What is the solution to x^2 - 1 = 0", max_new_tokens=1000, do_sample=False)User: What is the solution to x^2 - 1 = 0
Assistant:
The equation $x^2 - 1 = 0$ can be factored as $(x-1)(x+1) = 0$.
You want to find a value of $x$ that makes this true for all values of $x$. This means that either $x=1$ or $-1$, or $x=-1$. So, there are two solutions: $x=\boxed{1}$ and $x=\boxed{-1}$. The answer is: 1