repo นี้มีรหัสข้อมูลและแบบจำลองสำหรับกระดาษ TMLR 2024 "Tigerscore: ไปสู่การสร้างตัวชี้วัดที่อธิบายได้สำหรับงานสร้างข้อความทั้งหมด"
| ทรัพยากรอื่น ๆ |
|---|
| - คอลเล็กชั่น Tigerscore |
| - การสาธิต HuggingFace |
ในการใช้ไปป์ไลน์ Tigerscore โดยตรงคุณต้องติดตั้งเป็นแพ็คเกจ Python ก่อน
pip install git+https://github.com/TIGER-AI-Lab/TIGERScore.git โปรดตรวจสอบว่า torch.cuda.is_available() เป็น True สำหรับเครื่องในพื้นที่ของคุณหรือไม่
นอกจากนี้หากต้องการใช้ Tigerscore กับ VLLM ที่มีรายละเอียดที่นี่คุณต้องติดตั้ง VLLM ตามเอกสาร 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/cu118หากคุณต้องการใช้สคริปต์การฝึกอบรมให้ติดตั้งการอ้างอิงโดยเรียกใช้คำสั่งต่อไปนี้:
pip install -r requirements.txt หลังจากการติดตั้งคุณดีที่จะให้คะแนนการสร้างข้อความด้วยรหัส Exmaple Python ต่อไปนี้ (ดูใน tigerscore_example_usage.ipynb สำหรับกรณีการใช้งานเพิ่มเติม):
# 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 )ผลลัพธ์คือรายการของ dicts ที่ประกอบด้วยการวิเคราะห์ข้อผิดพลาดที่มีโครงสร้าง
[
{
"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 รองรับการอนุมาน VLLM อย่างรวดเร็ว ใน GPU A6000 (48GB) เดียวจะใช้เวลาเพียง 0.2s - 0.3s สำหรับ Tigerscore -13b เพื่อให้คะแนนแต่ละอินสแตนซ์
scorer = TIGERScorer ( model_name = "TIGER-Lab/TIGERScore-7B" , quantized = True ) # 4 bit quantization on GPU โดยการตั้งค่าพารามิเตอร์การเริ่มต้น quanitzed=True โมเดลจะถูกตั้งค่าเป็นโหลดในรุ่น 4 บิตด้วยการกอด face face load_in_4bit=True
โปรดทราบว่าแม้ว่าการใช้ปริมาณจะลดความต้องการหน่วยความจำโดยระยะขอบขนาดใหญ่ คุณสามารถเรียกใช้ Tigerscore บน GPU หน่วยความจำ 20+GB อย่างไรก็ตามความเร็วการอนุมานอาจช้ากว่าการใช้รุ่น BFLOAT16 ดั้งเดิม ขึ้นอยู่กับคุณที่จะทำการแลกเปลี่ยน
scorer = TIGERScorer ( model_name = "TIGER-Lab/TIGERScore-7B-GGUF" , use_llamacpp = True )นอกจากนี้เรายังให้บริการ Tigerscore-7b/13b เวอร์ชัน LLAMACPP ด้วยการใช้เวอร์ชัน GGUF ที่เราให้ไว้คุณสามารถเรียกใช้ Tigerscore บนอุปกรณ์ CPU บริสุทธิ์ โดยทั่วไปจะใช้เวลา 20s สำหรับ Tigerscore-13b ในการทำคะแนนแต่ละอินสแตนซ์
ชุดข้อมูลการประมวลผลล่วงหน้าและผลลัพธ์ระดับกลางสามารถดูได้ที่นี่
โฟลเดอร์ xgptscore มีเทมเพลตทั้งหมดที่เราใช้ในการสืบค้น chatgpt หรือ GPT-4 เพื่อรับข้อผิดพลาดที่ระบุในเอาท์พุทสมมติฐานสำหรับงานต่าง ๆ ที่ Tigerscore เกี่ยวข้อง เราเรียกวิธีการสืบค้น API เหล่านี้ว่า XGPTSCORE สำหรับวิธี การให้คะแนน AE X PONAINABLE โดยการสอบถามรุ่น GPT
ไปป์ไลน์โดยรวมของ XGPTScore คือ:
./constants.py ) ตรวจสอบ xgptscore/README.md สำหรับรายละเอียดเพิ่มเติม และวิธีการใช้เทมเพลตแบบสอบถามของเราด้วยฟังก์ชั่นเดียว xgptscore()
Metricinstruct ประกอบด้วยข้อมูลจาก 2 ช่องทางการสุ่มตัวอย่าง ช่องทางโลกแห่งความเป็นจริง และ ช่องทางสังเคราะห์
generate_distill_data.shgenerate_synthesis_distill_data.sh วัตถุประสงค์โดยรวมของการรวบรวมข้อมูลช่อง 2 ช่องคือเพื่อให้แน่ใจว่าเราครอบคลุมประเภทข้อผิดพลาดมากที่สุดในข้อมูลการฝึกอบรมเพื่อให้แบบจำลองของเราสรุปได้ดีขึ้นหลังจากได้รับข้อมูลเหล่านี้แล้วเราจะทำฮิวริสติกซีรี่ส์เพื่อกรองข้อมูลที่ไม่ดีและเพิ่มข้อมูล:
check_data.sh )generate_inst_synthetic_data.sh เป็นส่วนเสริมของช่องสังเคราะห์คุณสามารถโหลดข้อมูลที่ประมวลผลล่วงหน้าของเราที่ใช้ในการ finetune tigerscore-v1 จากการกอดใบหน้า? โดยตรง:
from datasets import load_dataset
dataset = load_dataset ( "TIGER-Lab/MetricInstruct" ) เราให้บริการการฝึกอบรมและการทดสอบสคริปต์ในโฟลเดอร์ finetune ที่เราใช้ที่ไหน?
finetune_llama.sh เพื่อ finetine รุ่นformat_distill_data.sh ในการแปลงข้อมูลเป็นรูปแบบสำหรับ finetuning นั่นคือคำสั่ง sinlge และบริบทอินพุตด้วยเอาต์พุตtest_llama_vllm.sh เพื่อทดสอบและคำนวณความสัมพันธ์เป็นประสิทธิภาพของโมเดล Finetuned ของเรา โปรดตรวจสอบสคริปต์เหล่านี้เพื่อทราบรายละเอียดเพิ่มเติมเกี่ยวกับกระบวนการฝึกอบรมและการทดสอบของเรา./tigerscore/common/README.md เพื่อติดตั้ง Env โปรดอ้างอิงกระดาษของเราหากคุณปรับข้อมูลโมเดลหรือรหัสของเราเป็นประโยชน์
@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}
}