hkust-nlp/deita-quality-scorer

Model

Model Card for Deita Quality Scorer

18

10 commits

1 linked in READMEs

updated Dec 29, 2023

See the code

README

Deita banner

Model Card for Deita Quality Scorer

GitHub | Paper

Deita is an open-sourced project designed to facilitate Automatic Data Selection for instruction tuning in Large Language Models (LLMs).

Deita Quality Scorer is a tool for automatically annotating the Instruction Quality of SFT data.

Model description

  • Model type: Model fine tuned to automatically annotate the Instruction-Response Pair Quality
  • Language(s) (NLP): Primarily English
  • Finetuned from model: Llama-1-13b-hf

Model Sources

Performance

ModelAlignData SizeMT-BenchAlpacaEval(%)OpenLLM (Avg.)
Proprietary Models
GPT-4-Turbo?--9.3297.70--
GPT-4SFT + PPO--8.9995.03--
Claude-2SFT + PPO--8.0691.36--
GPT-3.5-turboSFT + PPO--7.9489.37--
Open-sourced Models based on LLaMA-1-13B
LIMASFT1K SFT4.2941.9859.82
WizardLM-13BSFT70K SFT6.3575.3158.96
Vicuna-13B-v1.3SFT125K SFT6.3982.1160.01
RandomSFT10K SFT6.0371.5260.14
DEITA-LLaMA1-13B-v1.0-sftSFT10K SFT6.6078.0164.27
Open-sourced Models based on LLaMA-2-13B
Tulu-2-13BSFT326K SFT6.7078.90--
Tulu-2-13B+DPOSFT + DPO326K SFT + 60K DPO7.0089.50--
LLaMA2-13B-ChatSFT + PPO--6.6581.09--
WizardLM-13B-v1.2SFT>70K SFT7.0989.17--
Vicuna-13B-v1.5SFT125K SFT6.5778.8061.63
RandomSFT10K SFT5.7865.1961.32
DEITA-LLaMA2-13B-v1.0-sftSFT10K SFT6.7981.0962.71
Open-sourced Models based on Mistral-7B
Mistral-7B-Instruct-v0.1----6.8469.6560.45
Zephyr-7B-sftSFT200K SFT5.3275.1260.93
$\text{Zephyr-7B-}\beta$SFT + DPO200K SFT + 60K DPO7.3490.6066.36
OpenChat-3.5C-RLFT>> 70K C-RLFT7.8188.51--
Starling-7BC-RLFT + APA>>70K C-RLFT + 183K APA8.0991.99--
RandomSFT10K SFT5.8956.9061.72
DEITA-7B-v1.0-sft (6K)SFT6K SFT7.2280.7864.94
DEITA-7B-v1.0-sft (10K)SFT10K SFT7.3281.6764.00
DEITA-7B-v1.0SFT + DPO6K SFT + 10K DPO7.5590.0669.86

Usage

Please use the following format to score the quality of Instruction-Response Pair

from transformers import AutoTokenizer, AutoModelForCausalLM
import numpy as np
from scipy.special import softmax
model_name = "hkust-nlp/deita-quality-scorer"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)


def infer_Quality(model, tokenizer, input_text, resp_text):
	quality_template = ("You are a helpful assistant. Please identify the quality score of the Response corresponding to the Question. \n #Question#:\n{instruction}\n#Response#:\n{output} \n##Quality: ")
	user_input = quality_template.format(instruction=input_text, output=resp_text)
	input_ids = tokenizer.encode(user_input, return_tensors="pt")
	max_length = 512
	outputs = model.generate(input_ids, max_length=512, num_return_sequences=1, return_dict_in_generate=True, output_scores=True)
	logprobs_list = outputs.scores[0][0]
	score_logits = []
	id2score = {
        29896: "1",
        29906: "2",
        29941: "3",
        29946: "4",
        29945: "5",
        29953: "6"
    }
	score_template = np.array([1,2,3,4,5,6])
	for k in id2score:
	    score_logits.append(logprobs_list[k])
	score_logits = np.array(score_logits)
	score_npy = softmax(score_logits, axis=0)
	score_npy = score_npy * score_template

	score_npy = np.sum(score_npy, axis=0)
	return score_npy

input_text = "word to describe UI with helpful tooltips" # Example Input
output_text = "User-friendly or intuitive UI" # Example Output
quality_score = infer_quality(model, tokenizer, input_text)

print(quality_score)


Citation

If you find the content of this project helpful, please cite our paper as follows:

@misc{liu2023what,
      title={What Makes Good Data for Alignment? A Comprehensive Study of Automatic Data Selection in Instruction Tuning}, 
      author={Wei Liu and Weihao Zeng and Keqing He and Yong Jiang and Junxian He},
      year={2023},
      eprint={2312.15685},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
endpoints_compatible
llama
pytorch
text-generation
text-generation-inference
transformers

Contributors

AndrewZeng

10 commits

hkust-nlp/deita-quality-scorer

Model

Model Card for Deita Quality Scorer

18

10 commits

1 linked in READMEs

updated Dec 29, 2023

See the code

README

Deita banner

Model Card for Deita Quality Scorer

GitHub | Paper

Deita is an open-sourced project designed to facilitate Automatic Data Selection for instruction tuning in Large Language Models (LLMs).

Deita Quality Scorer is a tool for automatically annotating the Instruction Quality of SFT data.

Model description

  • Model type: Model fine tuned to automatically annotate the Instruction-Response Pair Quality
  • Language(s) (NLP): Primarily English
  • Finetuned from model: Llama-1-13b-hf

Model Sources

Performance

ModelAlignData SizeMT-BenchAlpacaEval(%)OpenLLM (Avg.)
Proprietary Models
GPT-4-Turbo?--9.3297.70--
GPT-4SFT + PPO--8.9995.03--
Claude-2SFT + PPO--8.0691.36--
GPT-3.5-turboSFT + PPO--7.9489.37--
Open-sourced Models based on LLaMA-1-13B
LIMASFT1K SFT4.2941.9859.82
WizardLM-13BSFT70K SFT6.3575.3158.96
Vicuna-13B-v1.3SFT125K SFT6.3982.1160.01
RandomSFT10K SFT6.0371.5260.14
DEITA-LLaMA1-13B-v1.0-sftSFT10K SFT6.6078.0164.27
Open-sourced Models based on LLaMA-2-13B
Tulu-2-13BSFT326K SFT6.7078.90--
Tulu-2-13B+DPOSFT + DPO326K SFT + 60K DPO7.0089.50--
LLaMA2-13B-ChatSFT + PPO--6.6581.09--
WizardLM-13B-v1.2SFT>70K SFT7.0989.17--
Vicuna-13B-v1.5SFT125K SFT6.5778.8061.63
RandomSFT10K SFT5.7865.1961.32
DEITA-LLaMA2-13B-v1.0-sftSFT10K SFT6.7981.0962.71
Open-sourced Models based on Mistral-7B
Mistral-7B-Instruct-v0.1----6.8469.6560.45
Zephyr-7B-sftSFT200K SFT5.3275.1260.93
$\text{Zephyr-7B-}\beta$SFT + DPO200K SFT + 60K DPO7.3490.6066.36
OpenChat-3.5C-RLFT>> 70K C-RLFT7.8188.51--
Starling-7BC-RLFT + APA>>70K C-RLFT + 183K APA8.0991.99--
RandomSFT10K SFT5.8956.9061.72
DEITA-7B-v1.0-sft (6K)SFT6K SFT7.2280.7864.94
DEITA-7B-v1.0-sft (10K)SFT10K SFT7.3281.6764.00
DEITA-7B-v1.0SFT + DPO6K SFT + 10K DPO7.5590.0669.86

Usage

Please use the following format to score the quality of Instruction-Response Pair

from transformers import AutoTokenizer, AutoModelForCausalLM
import numpy as np
from scipy.special import softmax
model_name = "hkust-nlp/deita-quality-scorer"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)


def infer_Quality(model, tokenizer, input_text, resp_text):
	quality_template = ("You are a helpful assistant. Please identify the quality score of the Response corresponding to the Question. \n #Question#:\n{instruction}\n#Response#:\n{output} \n##Quality: ")
	user_input = quality_template.format(instruction=input_text, output=resp_text)
	input_ids = tokenizer.encode(user_input, return_tensors="pt")
	max_length = 512
	outputs = model.generate(input_ids, max_length=512, num_return_sequences=1, return_dict_in_generate=True, output_scores=True)
	logprobs_list = outputs.scores[0][0]
	score_logits = []
	id2score = {
        29896: "1",
        29906: "2",
        29941: "3",
        29946: "4",
        29945: "5",
        29953: "6"
    }
	score_template = np.array([1,2,3,4,5,6])
	for k in id2score:
	    score_logits.append(logprobs_list[k])
	score_logits = np.array(score_logits)
	score_npy = softmax(score_logits, axis=0)
	score_npy = score_npy * score_template

	score_npy = np.sum(score_npy, axis=0)
	return score_npy

input_text = "word to describe UI with helpful tooltips" # Example Input
output_text = "User-friendly or intuitive UI" # Example Output
quality_score = infer_quality(model, tokenizer, input_text)

print(quality_score)


Citation

If you find the content of this project helpful, please cite our paper as follows:

@misc{liu2023what,
      title={What Makes Good Data for Alignment? A Comprehensive Study of Automatic Data Selection in Instruction Tuning}, 
      author={Wei Liu and Weihao Zeng and Keqing He and Yong Jiang and Junxian He},
      year={2023},
      eprint={2312.15685},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
endpoints_compatible
llama
pytorch
text-generation
text-generation-inference
transformers

Contributors

AndrewZeng

10 commits