Repo ini berisi kode, data, dan model untuk TMLR 2024 Paper "Tigerscore: Menuju Membangun Metrik yang Dapat Ditandai untuk Semua Tugas Pembuatan Teks"
| Sumber daya lainnya |
|---|
| ? Koleksi Tigerscore |
| ? Demo Huggingface |
Untuk secara langsung menggunakan pipa Tigerscore, pertama -tama Anda harus menginstalnya sebagai paket Python.
pip install git+https://github.com/TIGER-AI-Lab/TIGERScore.git Silakan periksa apakah torch.cuda.is_available() Anda True untuk mesin lokal Anda.
Selain itu, untuk menggunakan Tigerscore dengan VLLM terperinci di sini, Anda perlu menginstal VLLM berikut dengan dokumen VLLM.
pip install vllm
pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu121 # Replace `cp39` with your Python version (e.g., `cp38`, `cp39`, `cp311`).
pip install https://github.com/vllm-project/vllm/releases/download/v0.2.2/vllm-0.2.2+cu118-cp39-cp39-manylinux1_x86_64.whl
pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu118Jika Anda ingin menggunakan skrip pelatihan, instal dependensi dengan menjalankan perintah berikut:
pip install -r requirements.txt Setelah instalasi, Anda baik untuk mencetak generasi teks dengan kode python exmaple berikut (lihat di tigerscore_example_usage.ipynb untuk lebih banyak kasus penggunaan):
# gpu device setup
import os
os . environ [ "CUDA_VISIBLE_DEVICES" ] = "0"
# example
instruction = "Write an apology letter."
input_context = "Reason: You canceled a plan at the last minute due to illness."
hypo_output = "Hey [Recipient], n n I'm really sorry for ditching our plan. I suddenly got an opportunity for a vacation so I took it. I know this might have messed up your plans and I regret that. n n Despite being under the weather, I would rather go for an adventure. I hope you can understand my perspective and I hope this incident doesn't change anything between us. n n We can reschedule our plan for another time. Sorry again for the trouble. n n Peace out, n [Your Name] n n ---"
# Load and evaluate examples in all options in 3 lines of code
from tigerscore import TIGERScorer
scorer = TIGERScorer ( model_name = "TIGER-Lab/TIGERScore-7B" ) # on GPU
# scorer = TIGERScorer(model_name="TIGER-Lab/TIGERScore-7B", quantized=True) # 4 bit quantization on GPU
# scorer = TIGERScorer(model_name="TIGER-Lab/TIGERScore-7B", use_vllm=True) # VLLM on GPU
# scorer = TIGERScorer(model_name="TIGER-Lab/TIGERScore-7B-GGUF", use_llamacpp=True) # 4 bit quantization on CPU
results = scorer . score ([ instruction ], [ hypo_output ], [ input_context ])
# print the results, which is a list of json output containging the automatically parsed results!
print ( results )Hasilnya adalah daftar dikt yang terdiri dari analisis kesalahan terstruktur.
[
{
"num_errors" : 3 ,
"score" : -12.0 ,
"errors" : {
"error_0" : {
"location" : " " I'm really glad for ditching our plan. " " ,
"aspect" : " Inappropriate language or tone " ,
"explanation" : " The phrase " ditching our plan " is informal and disrespectful. It should be replaced with a more respectful and apologetic phrase like " cancelling our plan " . " ,
"severity" : " Major " ,
"score_reduction" : " 4.0 "
},
"error_1" : {
"location" : " " I suddenly got an opportunity for a vacation so I took it. " " ,
"aspect" : " Lack of apology or remorse " ,
"explanation" : " This sentence shows no remorse for cancelling the plan at the last minute. It should be replaced with a sentence that expresses regret for the inconvenience caused. " ,
"severity" : " Major " ,
"score_reduction" : " 4.0 "
},
"error_2" : {
"location" : " " I would rather go for an adventure. " " ,
"aspect" : " Incorrect reason for cancellation " ,
"explanation" : " This sentence implies that the reason for cancelling the plan was to go on an adventure, which is incorrect. The correct reason was illness. This sentence should be replaced with a sentence that correctly states the reason for cancellation. " ,
"severity" : " Major " ,
"score_reduction" : " 4.0 "
}
},
"raw_output" : " ... "
}
] scorer = TIGERScorer ( model_name = "TIGER-Lab/TIGERScore-7B" , use_vllm = True ) # VLLM on GPUTigerscore mendukung inferensi cepat VLLM. Pada GPU A6000 (48GB) tunggal, hanya membutuhkan 0,2S - 0,3 untuk Tigerscore -13b untuk mencetak setiap contoh.
scorer = TIGERScorer ( model_name = "TIGER-Lab/TIGERScore-7B" , quantized = True ) # 4 bit quantization on GPU Dengan mengatur parameter inisialisasi quanitzed=True , model diatur untuk dimuat dalam versi 4-bit dengan memeluk face load_in_4bit=True .
Harap dicatat bahwa meskipun menggunakan kuantisasi akan mengurangi persyaratan memori dengan margin besar. Anda dapat menjalankan Tigerscore di sekitar 20+GB memori GPU. Namun, kecepatan inferensi mungkin lebih lambat daripada menggunakan versi BFLOAT16 asli. Tergantung pada Anda untuk melakukan trade-off.
scorer = TIGERScorer ( model_name = "TIGER-Lab/TIGERScore-7B-GGUF" , use_llamacpp = True )Kami juga menyediakan versi LAMACPP dari Tigerscore-7b/13b. Dengan menggunakan versi GGUF yang kami berikan, Anda dapat menjalankan Tigerscore pada perangkat CPU murni. Biasanya membutuhkan 20-an untuk Tigerscore-13b untuk mencetak setiap contoh.
Skrip preprocessing dataset dan hasil menengah dapat ditemukan di sini
Folder xgptscore berisi semua templat yang kami gunakan untuk menanyakan chatgpt atau GPT-4 untuk mendapatkan kesalahan yang diidentifikasi dalam output hipotesis untuk berbagai tugas yang terlibat Tigerscore. Kami menyebut metode kueri API ini sebagai XGPTScore untuk metode penilaian AE X dengan menanyakan model GPT .
Pipa keseluruhan XGPTScore adalah:
./constants.py ) Periksa xgptscore/README.md untuk detail lebih lanjut. Dan cara menggunakan template kueri kami dengan satu fungsi xgptscore()
MetricInstruct terdiri dari data dari 2 saluran pengambilan sampel, saluran dunia nyata dan saluran sintetis .
generate_distill_data.sh .generate_synthesis_distill_data.sh . Tujuan keseluruhan dari 2 pengumpulan data saluran adalah untuk memastikan kami mencakup sebanyak tipe kesalahan dalam data pelatihan sehingga model kami menggeneralisasi lebih baik.Setelah mendapatkan data ini, kami melakukan heuristik seri untuk memfilter data buruk dan menambah data:
check_data.sh )generate_inst_synthetic_data.sh sebagai suplemen ke saluran sintetis.Anda dapat memuat data preproses kami yang digunakan untuk finetune tigerscore-v1 dari wajah pelukan? secara langsung:
from datasets import load_dataset
dataset = load_dataset ( "TIGER-Lab/MetricInstruct" ) Kami memberikan skrip pelatihan dan pengujian kami di folder finetune , di mana kami menggunakan?
finetune_llama.sh untuk finetine model.format_distill_data.sh untuk mengubah data menjadi format untuk finetuning, yaitu, instruksi sinlge dan konteks input dengan output.test_llama_vllm.sh untuk menguji dan menghitung korelasi sebagai kinerja model finetuned kami. Silakan periksa skrip ini untuk mengetahui detail lebih lanjut tentang proses pelatihan dan pengujian kami../tigerscore/common/README.md untuk menginstal env. Harap kutip makalah kami jika Anda mendenda data, model, atau kode yang berguna.
@article{Jiang2023TIGERScoreTB,
title={TIGERScore: Towards Building Explainable Metric for All Text Generation Tasks},
author={Dongfu Jiang and Yishan Li and Ge Zhang and Wenhao Huang and Bill Yuchen Lin and Wenhu Chen},
journal={ArXiv},
year={2023},
volume={abs/2310.00752},
url={https://api.semanticscholar.org/CorpusID:263334281}
}