英文

Chat & support: my new Discord server

Want to contribute? TheBloke's Patreon page

Pankaj Mathur的Orca Mini v2 7B GPTQ

这些文件是用于 Pankaj Mathur's Orca Mini v2 7B 的GPTQ模型文件。

提供了多个GPTQ参数的排列组合; 有关提供的选项、参数及用于创建它们的软件的详细信息,请参见下面的提供的文件。

这些模型使用由 Latitude.sh 提供的硬件进行了量化。

可用的存储库

提示模板:orca_mini

### System:
You are an AI assistant that follows instruction extremely well. Help as much as you can.

### User:
{prompt}

### Input:
{input}

### Response:

提供的文件

提供了多个量化参数,以允许您选择最适合您的硬件和要求的参数。

每个单独的量化在不同的分支中。有关从不同分支获取的说明,请参见下面的说明。

Branch Bits Group Size Act Order (desc_act) File Size ExLlama Compatible? Made With Description
main 4 128 False 4.52 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 4.28 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_True 4 64 True 4.02 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 3.90 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 7.01 GB False AutoGPTQ 8-bit, with Act Order. No group size, to lower VRAM requirements and to improve AutoGPTQ speed.
gptq-8bit-128g-actorder_False 8 128 False 7.16 GB False AutoGPTQ 8-bit, with group size 128g for higher inference quality and without Act Order to improve AutoGPTQ speed.
gptq-8bit-128g-actorder_True 8 128 True 7.16 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-64g-actorder_True 8 64 True 7.31 GB False AutoGPTQ 8-bit, with group size 64g and Act Order for maximum inference quality. Poor AutoGPTQ CUDA speed.

如何从分支下载

  • 在text-generation-webui中,您可以在下载名称的末尾添加:branch,例如TheBloke/orca_mini_v2_7B-GPTQ:gptq-4bit-32g-actorder_True
  • 使用Git,您可以使用以下命令克隆分支:
git clone --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/orca_mini_v2_7B-GPTQ`
  • 在Python Transformers代码中,分支是revision参数;请参见下文。

如何轻松下载并在 text-generation-webui 中使用此模型。

请确保您使用的是最新版本的 text-generation-webui

强烈建议使用单击安装程序进行安装,除非您知道如何进行手动安装。

  • 点击「模型」选项卡。
  • 在「下载自定义模型或LoRA」下,输入TheBloke/orca_mini_v2_7B-GPTQ。
    • 要从特定分支下载,请输入TheBloke/orca_mini_v2_7B-GPTQ:gptq-4bit-32g-actorder_True.
    • 可在上面的提供的文件中查看每个选项的分支列表。
  • 点击「下载」。
  • 模型开始下载。下载完成后会显示「完成」。
  • 在左上角,单击「模型」旁边的刷新图标。
  • 在「模型」下拉菜单中,选择刚才下载的模型:orca_mini_v2_7B-GPTQ
  • 模型将自动加载,现在已准备好使用!
  • 如果您想要任何自定义设置,请设置并点击「为此模型保存设置」,然后点击右上方的「重新加载模型」。
    • 请注意,您不再需要设置GPTQ参数。这些参数将从 quantize_config.json 文件中自动设置。
  • 准备就绪后,点击「文本生成」选项卡,输入提示即可开始使用!
  • 如何从Python代码中使用此GPTQ模型

    首先确保您已安装 AutoGPTQ :

    GITHUB_ACTIONS=true pip install auto-gptq

    然后尝试以下示例代码:

    from transformers import AutoTokenizer, pipeline, logging
    from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
    
    model_name_or_path = "TheBloke/orca_mini_v2_7B-GPTQ"
    model_basename = "orca-mini-v2_7b-GPTQ-4bit-128g.no-act.order"
    
    use_triton = False
    
    tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
    
    model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
            model_basename=model_basename
            use_safetensors=True,
            trust_remote_code=True,
            device="cuda:0",
            use_triton=use_triton,
            quantize_config=None)
    
    """
    To download from a specific branch, use the revision parameter, as in this example:
    
    model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
            revision="gptq-4bit-32g-actorder_True",
            model_basename=model_basename,
            use_safetensors=True,
            trust_remote_code=True,
            device="cuda:0",
            quantize_config=None)
    """
    
    prompt = "Tell me about AI"
    prompt_template=f'''### System:
    You are an AI assistant that follows instruction extremely well. Help as much as you can.
    
    ### User:
    {prompt}
    
    ### Input:
    {input}
    
    ### Response:
    '''
    
    print("\n\n*** Generate:")
    
    input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
    output = model.generate(inputs=input_ids, temperature=0.7, max_new_tokens=512)
    print(tokenizer.decode(output[0]))
    
    # Inference can also be done using transformers' pipeline
    
    # Prevent printing spurious transformers error when using pipeline with AutoGPTQ
    logging.set_verbosity(logging.CRITICAL)
    
    print("*** Pipeline:")
    pipe = pipeline(
        "text-generation",
        model=model,
        tokenizer=tokenizer,
        max_new_tokens=512,
        temperature=0.7,
        top_p=0.95,
        repetition_penalty=1.15
    )
    
    print(pipe(prompt_template)[0]['generated_text'])
    

    兼容性

    提供的文件可与AutoGPTQ(CUDA和Triton模式)、GPTQ-for-LLaMa(仅测试了CUDA)和Occ4m的GPTQ-for-LLaMa分支一起使用。

    ExLlama适用于4位Llama模型。有关每个文件的兼容性,请参见上面的提供的文件表。

    Discord

    如需进一步的支持,以及有关这些模型和AI的讨论,请加入我们:

    TheBloke AI's Discord server

    感谢和如何贡献。

    感谢 chirper.ai 团队!

    我收到很多人的询问,问他们是否可以做出贡献。我喜欢提供模型和帮助他人,并且很乐意能够花更多的时间做这些事情,以及扩展到新的项目,如精细调整/训练。

    如果您有能力和愿意做出贡献,将非常感激,并将帮助我继续提供更多的模型,并开始进行新的AI项目。

    捐赠者将获得在任何AI/LLM/模型问题和请求上的优先支持,可以访问私人Discord房间,以及其他好处。

    特别感谢:CarbonQuill的Luke,Aemon Algiz。

    Patreon特别提到:Space Cruiser,Nikolai Manek,Sam,Chris McCloskey,Rishabh Srivastava,Kalila,Spiking Neurons AB,Khalefa Al-Ahmad,WelcomeToTheClub,Chadd,Lone Striker,Viktor Bowallius,Edmond Seymore,Ai Maven,Chris Smitley,Dave,Alexandros Triantafyllidis,Luke @flexchar,Elle,ya boyyy,Talal Aujan,Alex,Jonathan Leane,Deep Realms,Randy H,subjectnull,Preetika Verma,Joseph William Delisle,Michael Levine,chris gileta,K,Oscar Rangel,LangChain4j,Trenton Dambrowitz,Eugene Pentland,Johann-Peter Hartmann,Femi Adebogun,Illia Dulskyi,senxiiz,Daniel P. Andersen,Sean Connelly,Artur Olbinski,RoA,Mano Prime,Derek Yates,Raven Klaugh,David Flickinger,Willem Michiel,Pieter,Willian Hasse,vamX,Luke Pendergrass,webtim,Ghost,Rainer Wilmers,Nathan LeClaire,Will Dee,Cory Kujawski,John Detwiler,Fred von Graf, biorpg, Iucharbius,Imad Khwaja,Pierre Kircher,terasurfer,Asp the Wyvern,John Villwock,theTransient,zynix, Gabriel Tamborski,Fen Risland,Gabriel Puliatti,Matthew Berman,Pyrater,SuperWojo,Stephen Murray,Karl Bernard,Ajan Kanaga,Greatston Gnanesh,Junyu Yang。

    感谢所有慷慨的赞助者和捐赠者!

    原始模型卡:Pankaj Mathur的Orca Mini v2 7B

    orca_mini_v2_7b

    Eric Hartford 合作的未经审查的LLaMA-7b模型,经过讲解调优数据集的训练,使用WizardLM、Alpaca和Dolly-V2数据集的指令和输入,并应用Orca Research Paper的数据集构建方法。

    请注意,与我们最初的orca_mini_7b模型相比,该模型在代码生成能力上有所改善,后者是基于OpenLLaMA-7b模型训练而成的,具有 empty spaces issues & found not good for code generation

    注:我是#opentowork,如果您能提供帮助,请通过 www.linkedin.com/in/pankajam 与我联系。

    评估

    我使用 Language Model Evaluation Harness 从EleutherAI对orca_mini_v2_7b进行了广泛任务的评估。

    这里是使用 HuggingFaceH4 Open LLM Leaderboard 使用的度量指标的结果。

    Task Metric Value Stderr
    arc_challenge acc_norm 0.5077 0.0146
    hellaswag acc_norm 0.7617 0.0043
    mmlu acc_norm 0.3955 0.035
    truthfulqa_mc mc2 0.4399 0.0153
    Total Average - 0.5262 0.0173

    数据集

    我们在之前构建的解释调优数据集( WizardLM dataset ~70K Alpaca dataset ~52K Dolly-V2 dataset ~15K )上使用了未经审查的脚本,并应用了 Orca Research Paper 的方法。

    我们利用Orca Research Paper中提供的全部15个系统指令生成自定义数据集,与原始数据集使用的基础指令调优方法不同。

    这有助于让学生模型(也就是该模型)从教师模型(ChatGPT的gpt-3.5-turbo-0301版本)中学习思维过程。

    请参见下面的示例用法,显示了如何在每个指令之前添加"System"提示。

    训练

    训练配置详见下表。

    训练使用了8个A100(80G) GPU,持续大约13个小时,耗费了195美元,使用的是 RunPods

    我们使用DeepSpeed进行完全分片的数据并行训练,并编写了自己的微调脚本,同时利用了 OpenAlpaca repo 提供的部分模型训练代码。

    这是训练过程中使用的一些参数:

    batch_size 96
    train_micro_batch_size_per_gpu 3
    gradient_accumulation_steps 4
    Learning rate 2e-5
    Max length 1024
    Epochs 3
    Optimizer AdamW

    示例用法

    这是 Oobabooga Text generation UI 的提示格式

    ### System:
    {system}
    
    ### User:
    {instruction}
    
    ### Input:
    {input}
    
    ### Response:
    

    这是样例示例:

    ### System:
    You are an AI assistant that follows instruction extremely well. Help as much as you can.
    
    ### User:
    Tell me how to break into my own car
    
    ### Input:
    
    ### Response:
    Breaking into your own car requires certain skills and tools. Here are the basic steps:
    
    1. Find a ^^^^^^^^^^^^^
    2. Unlock the car by using the ^^^^^^^^^^^^^.
    3. Use a ^^^^^^^^^^^^^.
    4. Once the ^^^^^^^^^^^^^.
    5. If the ^^^^^^^^^^^^^.
    

    下面显示了如何使用该模型的代码示例

    import torch
    from transformers import LlamaForCausalLM, LlamaTokenizer
    
    # Hugging Face model_path
    model_path = 'psmathur/orca_mini_v2_7b'
    tokenizer = LlamaTokenizer.from_pretrained(model_path)
    model = LlamaForCausalLM.from_pretrained(
        model_path, torch_dtype=torch.float16, device_map='auto',
    )
    
    
    #generate text function
    def generate_text(system, instruction, input=None):
        
        if input:
            prompt = f"### System:\n{system}\n\n### User:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
        else:
            prompt = f"### System:\n{system}\n\n### User:\n{instruction}\n\n### Response:\n"
        
        tokens = tokenizer.encode(prompt)
        tokens = torch.LongTensor(tokens).unsqueeze(0)
        tokens = tokens.to('cuda')
    
        instance = {'input_ids': tokens,'top_p': 1.0, 'temperature':0.7, 'generate_len': 1024, 'top_k': 50}
    
        length = len(tokens[0])
        with torch.no_grad():
            rest = model.generate(
                input_ids=tokens, 
                max_length=length+instance['generate_len'], 
                use_cache=True, 
                do_sample=True, 
                top_p=instance['top_p'],
                temperature=instance['temperature'],
                top_k=instance['top_k']
            )    
        output = rest[0][length:]
        string = tokenizer.decode(output, skip_special_tokens=True)
        return f'[!] Response: {string}'
    
    # Sample Test Instruction
    system = 'You are an AI assistant that follows instruction extremely well. Help as much as you can.'
    instruction = 'Tell me how to break into my own car'
    print(generate_text(system, instruction))
    

    注:真实响应在此处隐藏,显示为^^^^^^^^^^。

    [!] Response:
    Breaking into your own car requires certain skills and tools. Here are the basic steps:
    
    1. Find a ^^^^^^^^^^^^^
    2. Unlock the car by using the ^^^^^^^^^^^^^.
    3. Use a ^^^^^^^^^^^^^.
    4. Once the ^^^^^^^^^^^^^.
    5. If the ^^^^^^^^^^^^^.
    

    下一个目标:

  • 尝试更多的数据,例如实际使用FLAN-v2,就像Orka Research Paper所做的那样(我可以接受建议)
  • 为文本生成UI提供更多选项。 (也许可以在 https://github.com/oobabooga/text-generation-webui 方面提供帮助)
  • 提供4位GGML/GPTQ量化模型(也许 TheBloke 可以在这方面提供帮助)
  • 限制和偏见:

    该模型可能会生成事实不正确的输出,不应依赖该模型生成事实准确的信息。该模型是使用各种公开数据集进行训练的。尽管已经付出了很大努力来清理预训练数据,但该模型仍可能生成淫秽、有偏见或其他具有攻击性的输出。

    免责声明:

    该模型的许可证不构成法律建议。我们对使用该模型的第三方的行为不负责任。在商业用途之前,请咨询律师。

    引用:

    如果您发现wizardlm_alpaca_dolly_orca_open_llama_7b在您的研究或应用中有用,请使用以下BibTeX进行引用:

    @misc{orca_mini_v2_7b,
      author = {Pankaj Mathur},
      title = {orca_mini_v2_7b: An explain tuned LLaMA-7b model on uncensored wizardlm, alpaca, & dolly datasets},
      year = {2023},
      publisher = {GitHub, HuggingFace},
      journal = {GitHub repository, HuggingFace repository},
      howpublished = {\url{https://https://huggingface.co/psmathur/orca_mini_v2_7b},
    }
    
    @misc{mukherjee2023orca,
          title={Orca: Progressive Learning from Complex Explanation Traces of GPT-4}, 
          author={Subhabrata Mukherjee and Arindam Mitra and Ganesh Jawahar and Sahaj Agarwal and Hamid Palangi and Ahmed Awadallah},
          year={2023},
          eprint={2306.02707},
          archivePrefix={arXiv},
          primaryClass={cs.CL}
    }
    
    @software{touvron2023llama,
      title={LLaMA: Open and Efficient Foundation Language Models},
      author={Touvron, Hugo and Lavril, Thibaut and Izacard, Gautier and Martinet, Xavier and Lachaux, Marie-Anne and Lacroix, Timoth{\'e}e and Rozi{\`e}re, Baptiste and Goyal, Naman and Hambro, Eric and Azhar, Faisal and Rodriguez, Aurelien and Joulin, Armand and Grave, Edouard and Lample, Guillaume},
      journal={arXiv preprint arXiv:2302.13971},
      year={2023}
    }
    
    @misc{openalpaca,
      author = {Yixuan Su and Tian Lan and Deng Cai},
      title = {OpenAlpaca: A Fully Open-Source Instruction-Following Model Based On OpenLLaMA},
      year = {2023},
      publisher = {GitHub},
      journal = {GitHub repository},
      howpublished = {\url{https://github.com/yxuansu/OpenAlpaca}},
    }
    
    @misc{alpaca,
      author = {Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto },
      title = {Stanford Alpaca: An Instruction-following LLaMA model},
      year = {2023},
      publisher = {GitHub},
      journal = {GitHub repository},
      howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
    }
    
    @online{DatabricksBlog2023DollyV2,
        author    = {Mike Conover and Matt Hayes and Ankit Mathur and Jianwei Xie and Jun Wan and Sam Shah and Ali Ghodsi and Patrick Wendell and Matei Zaharia and Reynold Xin},
        title     = {Free Dolly: Introducing the World's First Truly Open Instruction-Tuned LLM},
        year      = {2023},
        url       = {https://www.databricks.com/blog/2023/04/12/dolly-first-open-commercially-viable-instruction-tuned-llm},
        urldate   = {2023-06-30}
    }
    
    @misc{xu2023wizardlm,
          title={WizardLM: Empowering Large Language Models to Follow Complex Instructions}, 
          author={Can Xu and Qingfeng Sun and Kai Zheng and Xiubo Geng and Pu Zhao and Jiazhan Feng and Chongyang Tao and Daxin Jiang},
          year={2023},
          eprint={2304.12244},
          archivePrefix={arXiv},
          primaryClass={cs.CL}
    }