¿Piel? Se basa en la biblioteca de procesamiento del lenguaje natural de la arquitectura Kakaove Lane Pororo, agregando una función de API HyperClova X de HyperClova X Modelo de lenguaje grande (LLM) y la función HyperClova X de Naver. Admite las herramientas necesarias para el trapo (trapo).
python>=3.8 funciona normalmente en un entorno.
Puede instalar el paquete a través del comando a continuación.
pip install ragcar git clone https://github.com/leewaay/ragcar.git
cd ragcar
pip install -e . Puede usar Ragcar con el siguiente comando:
Ragcar , debe ejecutar el siguiente comando: > >> from ragcar import RagcarRagcar a través del siguiente comando. > >> 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 que busca antes 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
} Cierto src requiere variables de entorno ( clave API ) que requiere seguridad y mantenimiento, y se puede establecer como uno de los siguientes tres métodos:
.env archivo: cree un archivo .env en la ruta superior del proyecto e ingrese los valores variables de entorno necesarios. export OPENAI_API_KEY= ' sk-... 'model : ingrese la variable de entorno requerida directamente al valor del factor del modelo. ( Aplique lo mismo incluso si necesita agregarlo además del model predeterminado ) > >> 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 se calcula de manera diferente dependiendo de la API utilizada al usar la herramienta Text_Generation . Para OpenAI, predicted_cost es calculado por el dólar (USD) , y Clova se calcula como el original (KRW) . Esto se debe a que el sistema de facturación de cada servicio es diferente. La información de carga específica de acuerdo con el modelo actual se puede encontrar en el archivo base.py.
Cuando use tool Text_Generation con Clova src , tenga cuidado con los cambios que se han cambiado en comparación con algún parámetro oficial:
Cambio de nombre del parámetro :
presence_penalty en lugar de top_k .frequency_penalty en lugar de repeat_penalty .Rango de valor de parámetro :
0.0 < temperature < 1.00.0 < top_p < 1.00 < presence_penalty < 1280.0 < frequency_penalty < 10.0Sentence_embedding Ejemplo de verificación
Si tiene alguna pregunta u opinión, deje un problema.
@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 " ,
}