CoolFace
Modelpublic

hiyouga/Llama-2-70b-AQLM-2Bit-QLoRA-function-calling

sourceHugging Facellama2updated 3y agoView on Hugging Face
8likes10downloads
Model Card

<!-- This model card has been generated automatically according to the information the Trainer had access to. You should probably proofread and complete it, then remove this comment. -->

LLaMA-2 70B AQLM 2-bit QLoRA with function calling

This model is fine-tuned from BlackSamorez/Llama-2-70b-AQLM-2Bit-1x16-hf using LLaMA Factory.

The maximum GPU usage during training is 24GB, and the model has preliminary conversation and tool-using abilities.

It requires at least 20GB GRAM at inference.

[image]

Training and evaluation data

This model is fine-tuned using 2,000 examples of the Alpaca-GPT4 and Glaive-function-calling-v2 datasets.

Usage

python
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
from peft import PeftModel

tokenizer = AutoTokenizer.from_pretrained("hiyouga/Llama-2-70b-AQLM-2Bit-QLoRA-function-calling")
model = AutoModelForCausalLM.from_pretrained("BlackSamorez/Llama-2-70b-AQLM-2Bit-1x16-hf", torch_dtype="auto", device_map="auto")
model = PeftModel.from_pretrained(model, "hiyouga/Llama-2-70b-AQLM-2Bit-QLoRA-function-calling")
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)

messages = [
    {
      "role": "system",
      "content": (
        "You have access to the following tools:\n"
        "> Tool Name: get_current_weather\nTool Description: Get the current weather in a given location\n"
        "Tool Args:\n"
        "  - location (string, required): The city and state, e.g. San Francisco, CA\n"
        "  - unit (string): should be one of [\"celsius\", \"fahrenheit\"]\n\n"
        "Use the following format if using a tool:\n"
        "```\n"
        "Action: tool name (one of [get_current_weather]).\n"
        "Action Input: the input to the tool, in a JSON format representing the kwargs "
        "(e.g. ```{\"input\": \"hello world\", \"num_beams\": 5}```).\n"
        "```\n"
      )
    },
    {"role": "user", "content": "What is the weather like in Boston?"}
]
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
inputs = inputs.to("cuda")
generate_ids = model.generate(inputs, streamer=streamer)

Training procedure

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 0.0001
  • trainbatchsize: 1
  • evalbatchsize: 8
  • seed: 42
  • gradientaccumulationsteps: 8
  • totaltrainbatch_size: 8
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • lrschedulertype: cosine
  • num_epochs: 1.0
  • mixedprecisiontraining: Native AMP

Training results

[image]

Benchmark results

MMLU BenchmarkBitsMetricAccurary
Average25-shot, top-162.38
STEM25-shot, top-151.57
Social Sciences25-shot, top-173.44
Humanities25-shot, top-157.82
Other25-shot, top-168.56

Framework versions

  • PEFT 0.9.0
  • Transformers 4.39.0.dev0
  • Pytorch 2.2.1+cu121
  • Datasets 2.15.0
  • Tokenizers 0.15.2