pip uninstall -y auto-gptq
git clone https://github.com/PanQiWei/AutoGPTQ
cd AutoGPTQ
set GITHUB_ACTIONS=true
pip install .
Trust Remote Code
As this is a new model type, not yet supported by Transformers, you must run inference with Trust Remote Code set.
Using text-generation-webui, this can be done by ticking "Trust Remote Code" in the UI, or by passing --trust-remote-code on the command line.
In Python code, please pass trust_remote_code=True to both the AutoTokenizer.from_pretrained() and AutoGPTQForCausalLM.from_quantized() calls.
Prompt template
A general prompt template is unknown at this point.
The example given in the README is a 1-shot categorisation:
Hamlet->Shakespeare\nOne Hundred Years of Solitude->
How to easily download and use this model in text-generation-webui
Please make sure you're using the latest version of text-generation-webui
Click the Model tab.
Untick Autoload
Under Download custom model or LoRA, enter TheBloke/baichuan-7B-GPTQ.
Click Download.
The model will start downloading. Once it's finished it will say "Done"
Choose the AutoGPTQ loader.
In the top left, click the refresh icon next to Model.
In the Model dropdown, choose the model you just downloaded: baichuan-7B-GPTQ
Tick "Trust Remote Code". Then click Save Settings followed by Reload
The model will automatically load, and is now ready for use!
Once you're ready, click the Text Generation tab and enter a prompt to get started!
How to use this GPTQ model from Python code
First make sure you have the latest AutoGPTQ installed from source as mentioned above.
Then try the following example code:
python
1from transformers import AutoTokenizer
2from auto_gptq import AutoGPTQForCausalLM
34model_name_or_path ='TheBloke/baichuan-7B-GPTQ'5# Or you can clone the model locally and reference it on disk, eg with:6# model_name_or_path = "/path/to/TheBloke_baichuan-7B"78tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True)910model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,11 use_safetensors=True,12 device_map="auto",13 trust_remote_code=True)1415# This is the example from the Baichuan README16inputs = tokenizer('Hamlet->Shakespeare\nOne Hundred Years of Solitude->', return_tensors='pt')17inputs = inputs.to('cuda:0')18pred = model.generate(**inputs, max_new_tokens=64,repetition_penalty=1.1)19print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))2021# Here's my own example, which sometimes kind of works.22inputs = tokenizer('USER:Write a story about llamas\nASSISTANT:', return_tensors='pt')23inputs = inputs.to('cuda:0')24pred = model.generate(**inputs, max_new_tokens=500,repetition_penalty=1.1)25print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
Provided files
gptq_model-4bit-128g.safetensors
This will currently only work with the latest AutoGPTQ, compiled from source.
gptq_model-4bit-128g.safetensors
Works only with latest AutoGPTQ, compiled from source.
Requires trust_remote_code.
Works with text-generation-webui, but not yet with one-click-installers unless you manually re-compile AutoGPTQ.
Parameters: Groupsize = 128. Act Order / desc_act = False.
Discord
For further support, and discussions on these models and AI in general, join us at:
I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
Patreon special mentions: Sam, theTransient, Jonathan Leane, Steven Wood, webtim, Johann-Peter Hartmann, Geoffrey Montalvo, Gabriel Tamborski, Willem Michiel, John Villwock, Derek Yates, Mesiah Bishop, Eugene Pentland, Pieter, Chadd, Stephen Murray, Daniel P. Andersen, terasurfer, Brandon Frisco, Thomas Belote, Sid, Nathan LeClaire, Magnesian, Alps Aficionado, Stanislav Ovsiannikov, Alex, Joseph William Delisle, Nikolai Manek, Michael Davis, Junyu Yang, K, J, Spencer Kim, Stefan Sabev, Olusegun Samson, transmissions 11, Michael Levine, Cory Kujawski, Rainer Wilmers, zynix, Kalila, Luke @flexchar, Ajan Kanaga, Mandus, vamX, Ai Maven, Mano Prime, Matthew Berman, subjectnull, Vitor Caleffi, Clay Pascal, biorpg, alfie_i, 阿明, Jeffrey Morgan, ya boyyy, Raymond Fosdick, knownsqashed, Olakabola, Leonard Tan, ReadyPlayerEmma, Enrico Ros, Dave, Talal Aujan, Illia Dulskyi, Sean Connelly, senxiiz, Artur Olbinski, Elle, Raven Klaugh, Fen Risland, Deep Realms, Imad Khwaja, Fred von Graf, Will Dee, usrbinkat, SuperWojo, Alexandros Triantafyllidis, Swaroop Kallakuri, Dan Guido, John Detwiler, Pedro Madruga, Iucharbius, Viktor Bowallius, Asp the Wyvern, Edmond Seymore, Trenton Dambrowitz, Space Cruiser, Spiking Neurons AB, Pyrater, LangChain4j, Tony Hughes, Kacper Wikieł, Rishabh Srivastava, David Ziegler, Luke Pendergrass, Andrey, Gabriel Puliatti, Lone Striker, Sebastain Graf, Pierre Kircher, Randy H, NimbleBox.ai, Vadim, danny, Deo Leter
Thank you to all my generous patrons and donaters!
And thank you again to a16z for their generous grant.
baichuan-7B is an open-source large-scale pre-trained model developed by Baichuan Intelligent Technology. Based on the Transformer architecture, it is a model with 7 billion parameters trained on approximately 1.2 trillion tokens. It supports both Chinese and English, with a context window length of 4096. It achieves the best performance of its size on standard Chinese and English authoritative benchmarks (C-EVAL/MMLU).
If you wish to use baichuan-7B (for inference, finetuning, etc.), we recommend using the accompanying code library baichuan-7B.
The following is a task of performing 1-shot inference using baichuan-7B, where the author's name is given based on the work, with the correct output being "One Hundred Years of Solitude->Gabriel Garcia Marquez"
The overall model is based on the standard Transformer structure, and we have adopted the same model design as LLaMA:
Position Embedding: We use rotary-embedding, which is the position encoding scheme adopted by most models at this stage, and it has excellent extrapolation capabilities.
Feedforward Layer: We use SwiGLU. The feedforward changes to (8/3) times the size of the hidden layer, that is, 11008.
Layer Normalization: Pre-Normalization based on RMSNorm.
We have also open-sourced the training code that accompanies this model, allowing for efficient finetuning for downstream tasks. For more details, please refer to baichuan-7B.
Out-of-Scope Use
在没有充分评估风险和采取缓解措施的情况下投入生产使用;任何可能被视为不负责任或有害的使用案例。
Production use without adequate assessment of risks and mitigation; any use cases which may be considered irresponsible or harmful.
baichuan-7B can produce factually incorrect output, and should not be relied on to produce factually accurate information. baichuan-7B was trained on various public datasets. While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
In addition to Chinese, we also tested the model's performance in English.
MMLU
MMLU is an English evaluation dataset that includes 57 multiple-choice tasks, covering elementary mathematics, American history, computer science, law, etc. The difficulty ranges from high school level to expert level, making it a mainstream LLM evaluation dataset.
We adopted the open-source evaluation scheme, and the final 5-shot results are as follows:
Model
Humanities
Social Sciences
STEM
Other
Average
LLaMA-7B2
34.0
38.3
30.5
38.1
35.1
Falcon-7B1
-
-
-
-
35.0
mpt-7B1
-
-
-
-
35.6
ChatGLM-6B0
35.4
41.0
31.3
40.5
36.9
BLOOM 7B0
25.0
24.4
26.5
26.4
25.5
BLOOMZ 7B0
31.3
42.1
34.4
39.0
36.1
moss-moon-003-base (16B)0
24.2
22.8
22.4
24.4
23.6
moss-moon-003-sft (16B)0
30.5
33.8
29.3
34.4
31.9
baichuan-7B0
38.4
48.9
35.6
48.1
42.3
The superscript in the Model column indicates the source of the results.