GeneZC/MiniChat-2-3B

Model

MiniChat-2-3B

24

12 commits

1 linked in READMEs

updated Jun 27, 2024

See the code

README

MiniChat-2-3B

πŸ“‘ arXiv | πŸ‘» GitHub | πŸ€— HuggingFace-MiniMA | πŸ€— HuggingFace-MiniChat | πŸ€– ModelScope-MiniMA | πŸ€– ModelScope-MiniChat | πŸ€— HuggingFace-MiniChat-1.5 | πŸ€— HuggingFace-MiniMA-2 | πŸ€— HuggingFace-MiniChat-2

πŸ†• Updates from MiniChat-3B:

  • better base model MiniMA-2-3B;
  • better data mixture;
  • use of NEFTune;
  • use of DPO.

❗ Must comply with LICENSE of LLaMA2 since it is derived from LLaMA2.

A language model continued from MiniMA-3B and finetuned on both instruction and preference data.

Surpassing Vicuna-7B and approximating LLaMA-2-Chat-7B on MT-Bench.

teaser_b

Standard Benchmarks

MethodTFLOPsMMLU (5-shot)CEval (5-shot)DROP (3-shot)HumanEval (0-shot)BBH (3-shot)GSM8K (8-shot)
Mamba-2.8B4.6E925.5824.7415.727.3229.373.49
ShearedLLaMA-2.7B0.8E926.9722.8819.984.8830.483.56
BTLM-3B11.3E927.2026.0017.8410.9830.874.55
StableLM-3B72.0E944.7531.0522.3515.8532.5910.99
Qwen-1.8B23.8E944.0554.7512.9714.0230.8022.97
Phi-2-2.8B159.9E956.7434.0330.7446.9544.1355.42
LLaMA-2-7B84.0E946.0034.4031.5712.8032.0214.10
MiniMA-3B4.0E928.5128.2322.5010.9831.618.11
MiniChat-3B4.0E938.4036.4822.5818.2931.3629.72
MiniMA-2-3B13.4E940.1444.6523.1014.6331.438.87
MiniChat-2-3B13.4E946.1743.9130.2622.5634.9538.13

Instruction-following Benchmarks

MethodAlpacaEvalMT-BenchMT-Bench-ZH
GPT-495.289.188.96
Zephyr-7B-Beta90.607.346.27#
Vicuna-7B76.846.175.22#
LLaMA-2-Chat-7B71.376.275.43#
Qwen-Chat-7B--6.24
Phi-2-DPO81.37-1.59#$
StableLM-Zephyr-3B76.006.644.31#
Rocket-3B79.756.564.07#
Qwen-Chat-1.8B--5.65
MiniChat-3B48.82--
MiniChat-2-3B77.306.236.04

# specialized mainly for English.

$ finetuned without multi-turn instruction data.

The following is an example code snippet to use MiniChat-2-3B:

import torch

from transformers import AutoModelForCausalLM, AutoTokenizer

from conversation import get_default_conv_template

# MiniChat
tokenizer = AutoTokenizer.from_pretrained("GeneZC/MiniChat-2-3B", use_fast=False)
# GPU.
model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniChat-2-3B", use_cache=True, device_map="auto", torch_dtype=torch.float16).eval()
# CPU.
# model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniChat-2-3B", use_cache=True, device_map="cpu", torch_dtype=torch.float16).eval()

conv = get_default_conv_template("minichat")

question = "Implement a program to find the common elements in two arrays without using any extra data structures."
conv.append_message(conv.roles[0], question)
conv.append_message(conv.roles[1], None)
prompt = conv.get_prompt()
input_ids = tokenizer([prompt]).input_ids
output_ids = model.generate(
    torch.as_tensor(input_ids).cuda(),
    do_sample=True,
    temperature=0.7,
    max_new_tokens=1024,
)
output_ids = output_ids[0][len(input_ids[0]):]
output = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
# output: "def common_elements(arr1, arr2):\n    if len(arr1) == 0:\n        return []\n    if len(arr2) == 0:\n        return arr1\n\n    common_elements = []\n    for element in arr1:\n        if element in arr2:\n            common_elements.append(element)\n\n    return common_elements"
# Multiturn conversation could be realized by continuously appending questions to `conv`.

Bibtex

@article{zhang2023law,
    title={Towards the Law of Capacity Gap in Distilling Language Models},
    author={Zhang, Chen and Song, Dawei and Ye, Zheyu and Gao, Yan},
    year={2023},
    url={https://arxiv.org/abs/2311.07052}
}

Open LLM Leaderboard Evaluation Results

Detailed results can be found here

MetricValue
Avg.51.49
AI2 Reasoning Challenge (25-Shot)44.88
HellaSwag (10-Shot)67.69
MMLU (5-Shot)47.59
TruthfulQA (0-shot)49.64
Winogrande (5-shot)66.46
GSM8k (5-shot)32.68
conversational
endpoints_compatible
llama
model-index
pytorch
safetensors
text-generation
text-generation-inference
transformers

Contributors

GeneZC

10 commits

SFconvertbot

1 commits

GeneZC/MiniChat-2-3B

Model

MiniChat-2-3B

24

12 commits

1 linked in READMEs

updated Jun 27, 2024

See the code

README

MiniChat-2-3B

πŸ“‘ arXiv | πŸ‘» GitHub | πŸ€— HuggingFace-MiniMA | πŸ€— HuggingFace-MiniChat | πŸ€– ModelScope-MiniMA | πŸ€– ModelScope-MiniChat | πŸ€— HuggingFace-MiniChat-1.5 | πŸ€— HuggingFace-MiniMA-2 | πŸ€— HuggingFace-MiniChat-2

πŸ†• Updates from MiniChat-3B:

  • better base model MiniMA-2-3B;
  • better data mixture;
  • use of NEFTune;
  • use of DPO.

❗ Must comply with LICENSE of LLaMA2 since it is derived from LLaMA2.

A language model continued from MiniMA-3B and finetuned on both instruction and preference data.

Surpassing Vicuna-7B and approximating LLaMA-2-Chat-7B on MT-Bench.

teaser_b

Standard Benchmarks

MethodTFLOPsMMLU (5-shot)CEval (5-shot)DROP (3-shot)HumanEval (0-shot)BBH (3-shot)GSM8K (8-shot)
Mamba-2.8B4.6E925.5824.7415.727.3229.373.49
ShearedLLaMA-2.7B0.8E926.9722.8819.984.8830.483.56
BTLM-3B11.3E927.2026.0017.8410.9830.874.55
StableLM-3B72.0E944.7531.0522.3515.8532.5910.99
Qwen-1.8B23.8E944.0554.7512.9714.0230.8022.97
Phi-2-2.8B159.9E956.7434.0330.7446.9544.1355.42
LLaMA-2-7B84.0E946.0034.4031.5712.8032.0214.10
MiniMA-3B4.0E928.5128.2322.5010.9831.618.11
MiniChat-3B4.0E938.4036.4822.5818.2931.3629.72
MiniMA-2-3B13.4E940.1444.6523.1014.6331.438.87
MiniChat-2-3B13.4E946.1743.9130.2622.5634.9538.13

Instruction-following Benchmarks

MethodAlpacaEvalMT-BenchMT-Bench-ZH
GPT-495.289.188.96
Zephyr-7B-Beta90.607.346.27#
Vicuna-7B76.846.175.22#
LLaMA-2-Chat-7B71.376.275.43#
Qwen-Chat-7B--6.24
Phi-2-DPO81.37-1.59#$
StableLM-Zephyr-3B76.006.644.31#
Rocket-3B79.756.564.07#
Qwen-Chat-1.8B--5.65
MiniChat-3B48.82--
MiniChat-2-3B77.306.236.04

# specialized mainly for English.

$ finetuned without multi-turn instruction data.

The following is an example code snippet to use MiniChat-2-3B:

import torch

from transformers import AutoModelForCausalLM, AutoTokenizer

from conversation import get_default_conv_template

# MiniChat
tokenizer = AutoTokenizer.from_pretrained("GeneZC/MiniChat-2-3B", use_fast=False)
# GPU.
model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniChat-2-3B", use_cache=True, device_map="auto", torch_dtype=torch.float16).eval()
# CPU.
# model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniChat-2-3B", use_cache=True, device_map="cpu", torch_dtype=torch.float16).eval()

conv = get_default_conv_template("minichat")

question = "Implement a program to find the common elements in two arrays without using any extra data structures."
conv.append_message(conv.roles[0], question)
conv.append_message(conv.roles[1], None)
prompt = conv.get_prompt()
input_ids = tokenizer([prompt]).input_ids
output_ids = model.generate(
    torch.as_tensor(input_ids).cuda(),
    do_sample=True,
    temperature=0.7,
    max_new_tokens=1024,
)
output_ids = output_ids[0][len(input_ids[0]):]
output = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
# output: "def common_elements(arr1, arr2):\n    if len(arr1) == 0:\n        return []\n    if len(arr2) == 0:\n        return arr1\n\n    common_elements = []\n    for element in arr1:\n        if element in arr2:\n            common_elements.append(element)\n\n    return common_elements"
# Multiturn conversation could be realized by continuously appending questions to `conv`.

Bibtex

@article{zhang2023law,
    title={Towards the Law of Capacity Gap in Distilling Language Models},
    author={Zhang, Chen and Song, Dawei and Ye, Zheyu and Gao, Yan},
    year={2023},
    url={https://arxiv.org/abs/2311.07052}
}

Open LLM Leaderboard Evaluation Results

Detailed results can be found here

MetricValue
Avg.51.49
AI2 Reasoning Challenge (25-Shot)44.88
HellaSwag (10-Shot)67.69
MMLU (5-Shot)47.59
TruthfulQA (0-shot)49.64
Winogrande (5-shot)66.46
GSM8k (5-shot)32.68
conversational
endpoints_compatible
llama
model-index
pytorch
safetensors
text-generation
text-generation-inference
transformers

Contributors

GeneZC

10 commits

SFconvertbot

1 commits