Conformers
1.0.0
นี่คือการใช้งานแบบจำลองภาษาที่สอดคล้องกันอย่างไม่เป็นทางการ ฉันพบว่ากระดาษน่าสนใจและต้องการเล่นกับมัน ยังคงอยู่ในสถานะแรก ๆ - การรับประกันทางสถิติที่เข้มงวดเพียงอย่างเดียวในปัจจุบันคือมีข้อบกพร่องและความเข้าใจผิด โปรดแก้ตัวสถานะของรหัสปัจจุบัน - ฉันจะทำความสะอาดฉันสัญญา!
ยังไม่มีแพ็คเกจ PYPI ในการติดตั้งให้โคลนที่เก็บและเรียกใช้
pip install poetry
poetry installPython API ยังไม่ได้ตั้งอยู่ในหิน แต่จุดมุ่งหมายคือทำให้ง่ายต่อการทดลองด้วยการรับเข้าเรียนที่แตกต่างกันความมั่นใจของกลุ่มและฟังก์ชั่นการปฏิเสธ อาจมีการผสมผสานที่น่าสนใจบางอย่างด้วยกระดาษโมเดลภาษา CFG ล่าสุด ด้านล่างเป็นตัวอย่างที่มี GPT2
from conformer import Calibrator , Sampler , Components
import torch
from random import randint
x = [
"What is the capital of France?" ,
"Which prime-minster of the UK was the biggest nob?" ,
]
from transformers import GPT2LMHeadModel , GPT2Tokenizer
model_name = "gpt2"
model = GPT2LMHeadModel . from_pretrained ( model_name ). cuda ()
tokenizer = GPT2Tokenizer . from_pretrained ( model_name )
tokenizer . pad_token_id = tokenizer . eos_token_id
calibrator = Calibrator (
model = model ,
tokenizer = tokenizer ,
calibration_prompts = x ,
)
calibrator . set_admission_function ( Components . admission . debug )
calibrator . set_group_confidence_function ( Components . group_confidence . debug , torch . tensor ([ 0.1 , 0.5 , 1 ]))
calibrator . add_rejection_function ( Components . rejection . debug , torch . tensor ([ 0.1 , 0.5 , 1 ]))
calibrator . set_FWER ( Components . FWER . debug )
lambdaz = calibrator . search ()
sampler = Sampler . from_calibrator ( calibrator )
sampler . sample_with_rejection ( "What is the capital of France?" )สิ่งนี้ใช้ฟังก์ชั่นการรับสมัคร/GF/FWER/การปฏิเสธในตัว ยังสามารถใช้ฟังก์ชั่นของคุณเองเช่น:
calibrator . set_group_confidence_function ( lambda x : x > 0.5 , torch . tensor ([ 0.1 , 0.5 , 1 ]))