يحتوي هذا الريبو على الكود والبيانات والنماذج لورقة TMLR 2024 "Tigerscore: نحو بناء مقياس قابل للتفسير لجميع مهام توليد النص"
| موارد أخرى |
|---|
| ؟ مجموعات النمور |
| ؟ العانق العرضية |
لاستخدام خط أنابيب Tigerscore مباشرة ، تحتاج أولاً إلى تثبيته كحزمة بيثون.
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 بعد التثبيت ، من الجيد تسجيل الأجيال النصية برمز Python Exmaple التالي (انظر في 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 )النتائج هي قائمة بالديكتات التي تتكون من تحليل الخطأ منظم.
[
{
"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 GPUالنمور يدعم VLLM الاستدلال السريع. على وحدة معالجة الرسومات A6000 (48 جيجا بايت) واحدة ، يستغرق فقط 0.2s - 0.3s للـ Tigerscore -13B لتسجيل كل مثيل.
scorer = TIGERScorer ( model_name = "TIGER-Lab/TIGERScore-7B" , quantized = True ) # 4 bit quantization on GPU من خلال تعيين معلمة التهيئة quanitzed=True ، يتم تعيين النموذج ليتم تحميله في إصدار 4 بت مع معانقة load_in_4bit=True .
يرجى ملاحظة أنه على الرغم من أن استخدام القياس الكمي من شأنه أن يقلل من متطلبات الذاكرة بهامش كبير. يمكنك تشغيل Tigerscore على حوالي 20+GB Memory GPU. ومع ذلك ، قد تكون سرعة الاستدلال أبطأ من استخدام إصدار BFLOAT16 الأصلي. ذلك يعتمد عليك على جعل المفاضلة.
scorer = TIGERScorer ( model_name = "TIGER-Lab/TIGERScore-7B-GGUF" , use_llamacpp = True )نحن نقدم أيضًا إصدار Llamacpp من Tigerscore-7B/13B. باستخدام إصدار GGUF الذي قدمناه ، يمكنك تشغيل Tigerscore على أجهزة وحدة المعالجة المركزية الخالصة. يستغرق الأمر بشكل عام 20s لـ Tigerscore-13B لتسجيل كل مثيل.
يمكن العثور هنا
يحتوي المجلد xgptscore على جميع القوالب التي استخدمناها للاستعلام عن chatgpt أو GPT-4 للحصول على الأخطاء المحددة في إخراج الفرضية للمهام المختلفة التي تنطوي عليها نمور النمور. نحن نسمي طرق استعلام API هذه على أنها XGPTSCORE لطريقة التسجيل AE x planainable من خلال الاستعلام عن نماذج GPT .
خط الأنابيب الكلي لـ XGPTSCORE هو:
./constants.py ) تحقق من xgptscore/README.md لمزيد من التفاصيل. وكيفية استخدام قالب الاستعلام الخاص بنا مع وظيفة واحدة xgptscore()
يتكون MetricInstruct من بيانات من قناتين أخذ العينات ، والقناة الواقعية والقناة الاصطناعية .
generate_distill_data.sh .generate_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 لتحقيق النموذج.format_distill_data.sh لتحويل البيانات إلى تنسيق finetuning ، أي تعليمات sinlge وسياق الإدخال مع الإخراج.test_llama_vllm.sh لاختبار وحساب الارتباط كأداء لنموذجنا المحدود. يرجى التحقق من هذه البرامج النصية لمعرفة المزيد من التفاصيل عن عملية التدريب والاختبار لدينا../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}
}