mobicham commited on
Commit
fc36b78
1 Parent(s): 0ee1d30

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +113 -0
README.md CHANGED
@@ -1,3 +1,116 @@
1
  ---
2
  license: llama2
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: llama2
3
+ train: false
4
+ inference: false
5
+ pipeline_tag: text-generation
6
  ---
7
+
8
+ ## Llama-2-7b-chat-hf-4bit_g64-HQQ
9
+ 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/
10
+
11
+ ### Basic Usage
12
+ To run the model, install the HQQ library from https://github.com/mobiusml/hqq and use it as follows:
13
+ ``` Python
14
+ from hqq.models.llama_hf import LlamaHQQ
15
+ import transformers
16
+
17
+ model_id = 'mobiuslabsgmbh/Llama-2-7b-chat-hf-4bit_g64-HQQ'
18
+ #Load the tokenizer
19
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
20
+ #Load the model
21
+ model = LlamaHQQ.from_quantized(model_id)
22
+ ```
23
+
24
+ ### Basic Chat Example
25
+ ``` Python
26
+ import transformers
27
+ from hqq.models.llama_hf import LlamaHQQ
28
+
29
+ model_id = 'mobiuslabsgmbh/Llama-2-7b-chat-hf-4bit_g64-HQQ'
30
+ #Load the tokenizer
31
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
32
+ #Load the model
33
+ model = LlamaHQQ.from_quantized(model_id)
34
+
35
+ ##########################################################################################################
36
+ from threading import Thread
37
+
38
+ from sys import stdout
39
+ def print_flush(data):
40
+ stdout.write("\r" + data)
41
+ stdout.flush()
42
+
43
+ #Adapted from https://huggingface.co/spaces/huggingface-projects/llama-2-7b-chat/blob/main/app.py
44
+ def process_conversation(chat):
45
+ system_prompt = chat['system_prompt']
46
+ chat_history = chat['chat_history']
47
+ message = chat['message']
48
+
49
+ conversation = []
50
+ if system_prompt:
51
+ conversation.append({"role": "system", "content": system_prompt})
52
+ for user, assistant in chat_history:
53
+ conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
54
+ conversation.append({"role": "user", "content": message})
55
+
56
+ return tokenizer.apply_chat_template(conversation, return_tensors="pt").to('cuda')
57
+
58
+ def chat_processor(chat, max_new_tokens=100, do_sample=True):
59
+ tokenizer.use_default_system_prompt = False
60
+ streamer = transformers.TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
61
+
62
+ generate_params = dict(
63
+ {"input_ids": process_conversation(chat)},
64
+ streamer=streamer,
65
+ max_new_tokens=max_new_tokens,
66
+ do_sample=do_sample,
67
+ top_p=0.90,
68
+ top_k=50,
69
+ temperature= 0.6,
70
+ num_beams=1,
71
+ repetition_penalty=1.2,
72
+ )
73
+
74
+ t = Thread(target=model.generate, kwargs=generate_params)
75
+ t.start()
76
+
77
+ outputs = []
78
+ for text in streamer:
79
+ outputs.append(text)
80
+ print_flush("".join(outputs))
81
+
82
+ return outputs
83
+
84
+ ###################################################################################################
85
+
86
+ outputs = chat_processor({'system_prompt':"You are a helpful assistant.",
87
+ 'chat_history':[],
88
+ 'message':"How can I build a car?"
89
+ },
90
+ max_new_tokens=1000, do_sample=False)
91
+ ```
92
+
93
+ <b>Output</b>:
94
+
95
+ 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:
96
+
97
+ 1. Design and Planning: The first step in building a car is to design and plan its structure, layout, and functionality. This involves creating detailed drawings and models using computer-aided design (CAD) software or other tools.
98
+ 2. Material Selection: Once the design is finalized, the next step is to select the materials needed for construction, such as steel, aluminum, plastics, rubber, and other components. These materials must be carefully chosen based on their strength, durability, and compatibility with each other.
99
+ 3. Frame and Body Construction: The frame is the skeleton of the car, providing structural support and stability. It is typically made of steel or aluminum and is assembled by welding or bonding individual parts together. The body panels, which include the hood, doors, trunk lid, and roof, are attached to the frame using adhesives, rivets, or spot welds.
100
+ 4. Engine and Transmission Installation: The engine and transmission are critical components of any car, responsible for propelling it forward. The engine must be properly installed and connected to the transmission, which transfers power from the engine to the wheels.
101
+ 5. Electrical Systems: The electrical systems of a car include the battery, starter motor, alternator, and wiring harness. These components work together to provide power to the various accessories and systems within the vehicle, such as the lights, radio, and climate control.
102
+ 6. Suspension and Steering: The suspension system helps absorb shocks and bumps while driving, while the steering system allows the driver to maneuver the vehicle. Both of these systems require careful attention during the assembly process to ensure proper function and safety.
103
+ 7. Interior Fitting Out: Once the major components are in place, the interior of the car can be fitted out with seats, dashboard, carpeting, and other elements.
104
+ 8. Painting and Finishing: After all the components are in place, the car can be painted and finished according to personal preference or factory specifications.
105
+ 9. Testing and Quality Control: Before the car is ready for use, it undergoes rigorous testing and quality control measures to ensure that it meets safety and performance standards.
106
+
107
+ 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.
108
+
109
+ <p>
110
+
111
+ ----------------------------------------------------------------------------------------------------------------------------------
112
+ </p>
113
+
114
+ *Limitations*: <br>
115
+ -Only supports single GPU runtime.<br>
116
+ -Not compatible with HuggingFace's PEFT.<br>