راجار؟ يعتمد على مكتبة معالجة اللغة الطبيعية في الهندسة المعمارية Kakaove Lane Pororo ، مضيفًا نموذجًا لغويًا كبيرًا (LLM) Openai GPT و Naver's Hyperclova X API. وهو يدعم الأدوات اللازمة لخرقة (خرقة).
python>=3.8 إنه يعمل بشكل طبيعي في بيئة.
يمكنك تثبيت الحزمة من خلال الأمر أدناه.
pip install ragcar git clone https://github.com/leewaay/ragcar.git
cd ragcar
pip install -e . يمكنك استخدام Ragcar مع الأمر التالي:
Ragcar ، يجب عليك تشغيل الأمر التالي: > >> from ragcar import RagcarRagcar حاليًا من خلال الأمر التالي. > >> from ragcar import Ragcar
> >> Ragcar . available_tools ()
"Available tools are ['tokenization', 'sentence_embedding', 'sentence_similarity', 'semantic_search', 'text_generation', 'text_segmentation']" > >> Ragcar . available_models ( "text_generation" )
'Available models for text_generation are ([src]: openai, [model]: gpt-4-turbo-preview, gpt-4, gpt-3.5-turbo, MODELS_SUPPORTED(https://platform.openai.com/docs/models)), ([src]: clova, [model]: YOUR_MODEL(https://www.ncloud.com/product/aiService/clovaStudio))'src التي تنظر إليها قبل عامل tool . > >> from ragcar . utils import PromptTemplate
> >> prompt_template = PromptTemplate ( "사용자: {input} 수도는? n AI:" )
> >> generator = Ragcar ( tool = "text_generation" , src = "openai" , prompt_template = prompt_template , formatting = True ) > >> generator ( input = "대한민국" )
{
'id' : 'openai-dad4969f-6f0d-4413-a748-26d05cc0e73d' ,
'model' : 'gpt-4-turbo-preview' ,
'content' : '대한민국의 수도는 서울입니다.' ,
'finish_reason' : 'stop' ,
'input_tokens' : 23 ,
'output_tokens' : 15 ,
'total_tokens' : 38 ,
'predicted_cost' : 0.0015899999999999998 ,
'response_time' : 1.0608701705932617
} تتطلب بعض src متغيرات البيئة (على سبيل المثال
.env File: إنشاء ملف .env في المسار العلوي للمشروع وأدخل قيم متغير البيئة اللازمة. export OPENAI_API_KEY= ' sk-... 'model : أدخل متغير البيئة المطلوب مباشرة إلى قيمة عامل النموذج. ( ضع نفس الشيء حتى لو كنت بحاجة إلى إضافته بالإضافة إلى model الافتراضي ) > >> Ragcar . available_customizable_src ( "text_generation" )
"Available customizable src for text_generation are ['clova', 'openai']"
> >> Ragcar . available_model_fields ( "clova" )
'Available fields for clova are ([field]: model_n, [type]: str), ([field]: api_key, [type]: str), ([field]: app_key, [type]: str)' > >> generator = Ragcar (
tool = "text_generation" ,
src = "clova" ,
model = {
"model_n" : "YOUR_API_URL" ,
"api_key" : "YOUR_APIGW-API-KEY" ,
"app_key" : "YOUR_CLOVASTUDIO-API-KEY"
},
prompt_template = prompt_template ,
formatting = True
)
> >> generator ( input = "대한민국" )
{
'id' : 'clova-3c241fa1-f01e-4738-b208-5bcb35daad42' ,
'model' : 'HCX-003' ,
'content' : '대한민국 수도는 서울입니다.' ,
'finish_reason' : 'stop_before' ,
'input_tokens' : 12 ,
'output_tokens' : 8 ,
'total_tokens' : 20 ,
'predicted_cost' : 0.6 ,
'response_time' : 0.7090704441070557 ,
'ai_filter' : []
}Tool text_generation predicted_cost يتم احتساب predicted_cost بشكل مختلف اعتمادًا على واجهة برمجة التطبيقات المستخدمة عند استخدام أداة text_generation . بالنسبة لـ Openai ، يتم حساب predicted_cost بواسطة الدولار (USD) ، ويتم حساب Clova على أنه الأصلي (KRW) . وذلك لأن نظام الفواتير لكل خدمة مختلف. يمكن العثور على معلومات شحن محددة وفقًا للنموذج الحالي في ملف base.py.
عند استخدام tool text_generation مع Clova src ، كن حذرًا بشأن التغييرات التي تم تغييرها مقارنة ببعض المعلمات الرسمية:
تغيير اسم المعلمة :
presence_penalty بدلاً من top_k .frequency_penalty بدلاً من repeat_penalty .نطاق قيمة المعلمة :
0.0 < temperature < 1.00.0 < top_p < 1.00 < presence_penalty < 1280.0 < frequency_penalty < 10.0Sentence_embedding مثال تحقق
إذا كان لديك أي أسئلة أو آراء ، فيرجى ترك مشكلة.
@misc { pororo ,
author = { Heo, Hoon and Ko, Hyunwoong and Kim, Soohwan and
Han, Gunsoo and Park, Jiwoo and Park, Kyubyong } ,
title = { PORORO: Platform Of neuRal mOdels for natuRal language prOcessing } ,
howpublished = { url{https://github.com/kakaobrain/pororo} } ,
year = { 2021 } ,
} @inproceedings { reimers-2019-sentence-bert ,
title = " Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks " ,
author = " Reimers, Nils and Gurevych, Iryna " ,
booktitle = " Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing " ,
month = " 11 " ,
year = " 2019 " ,
publisher = " Association for Computational Linguistics " ,
url = " https://arxiv.org/abs/1908.10084 " ,
}