Downloads · 30 days
11
2% of all-time downloads
mobiuslabsgmbh/Llama-2-7b-chat-hf-4bit_g64-HQQ
Llama-2-7b-chat-hf-4bit_g64-HQQ is a text generation model from mobiuslabsgmbh. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as llama2.
This is a version of the LLama-2-7B-chat-hf model quantized to 4-bit via Half-Quadratic Quantization (HQQ): https://mobiusml.github.io/hqqblog/
Downloads · 30 days
11
2% of all-time downloads
All-time downloads
584
Public
Repo size
4.1 GB
Likes
3
Public
Click a slice to open those files.
.pt4.1 GB · 100%
From the Hugging Face model README
This is a version of the LLama-2-7B-chat-hf model quantized to 4-bit via Half-Quadratic Quantization (HQQ): https://mobiusml.github.io/hqq_blog/
To run the model, install the HQQ library:
#This model is deprecated and requires older versions
pip install hqq==0.1.8
pip install transformers==4.46.0
and use it as follows:
model_id = 'mobiuslabsgmbh/Llama-2-7b-chat-hf-4bit_g64-HQQ'
from transformers import AutoTokenizer
from hqq.models.hf.base import AutoHQQHFModel
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = HQQModelForCausalLM.from_quantized(model_id)
model_id = 'mobiuslabsgmbh/Llama-2-7b-chat-hf-4bit_g64-HQQ'
from transformers import AutoTokenizer
from hqq.models.hf.base import AutoHQQHFModel
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = HQQModelForCausalLM.from_quantized(model_id)
##########################################################################################################
import transformers
from threading import Thread
from sys import stdout
def print_flush(data):
stdout.write("\r" + data)
stdout.flush()
#Adapted from https://huggingface.co/spaces/huggingface-projects/llama-2-7b-chat/blob/main/app.py
def process_conversation(chat):
system_prompt = chat['system_prompt']
chat_history = chat['chat_history']
message = chat['message']
conversation = []
if system_prompt:
conversation.append({"role": "system", "content": system_prompt})
for user, assistant in chat_history:
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
conversation.append({"role": "user", "content": message})
return tokenizer.apply_chat_template(conversation, return_tensors="pt").to('cuda')
def chat_processor(chat, max_new_tokens=100, do_sample=True):
tokenizer.use_default_system_prompt = False
streamer = transformers.TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
generate_params = dict(
{"input_ids": process_conversation(chat)},
streamer=streamer,
max_new_tokens=max_new_tokens,
do_sample=do_sample,
top_p=0.90,
top_k=50,
temperature= 0.6,
num_beams=1,
repetition_penalty=1.2,
)
t = Thread(target=model.generate, kwargs=generate_params)
t.start()
outputs = []
for text in streamer:
outputs.append(text)
print_flush("".join(outputs))
return outputs
###################################################################################################
outputs = chat_processor({'system_prompt':"You are a helpful assistant.",
'chat_history':[],
'message':"How can I build a car?"
},
max_new_tokens=1000, do_sample=False)
<b>Output</b>:
Building a car is an incredibly complex and challenging project that requires extensive knowledge and expertise in various fields, including engineering, mechanics, design, and manufacturing. However, if you're interested in learning about the basics of how cars are built, here are some general steps involved:
Please note that this is a very high-level overview of the process, and actual car production involves many more details and considerations. Additionally, modern car manufacturing often relies heavily on automation and robotic processes, making the actual assembly line process much more complex than what is described above.
<p>Limitations: <br> -Only supports single GPU runtime.<br> -Not compatible with HuggingFace's PEFT.<br>