프롬프트 압축
는 계산 비용을 최소화하면서 이러한 모델의 성능을 향상시키는 데 중요한 기술로 등장했습니다. 거의 매주 새로운 연구가 떠오르면서 유지하는 것은 어렵지만 기본 사항을 이해하는 것은 필수적입니다.
이 기사는 신속 압축의 기본 사항을 다루고, 사용해야 할시기에 대해 설명하고 RAG 파이프 라인의 비용을 줄이는 데 중요성이 있으며 OpenAI의 API를 통해 GPT-3.5-Turbo-0125 모델을 사용하여 예제를 제공합니다.
토큰 제한 제약 조건 : llms는 입력에 대한 최대 토큰 제한을 갖습니다. 이 한계를 초과하면 중요한 정보를 자극하여 출력의 명확성과 모델의 효과를 줄일 수 있습니다. 처리 효율 및 비용 절감 :
토큰은 적은 수의 처리 시간과 비용이 낮아집니다. . 응답 관련성 향상 :인간이 읽을 수있는 프롬프트가 항상 좋은 프롬프트를 의미하는 것은 아닙니다. 때로는 우리가 선하고 유익한 유익한 소식은 중지 단어 ( "a," "," "is"등)와 같은 LLM에 대한 중요하지 않은 정보를 가져옵니다.
놀랍게도, 일부 인코딩 기술은 모델 탈옥에도 사용되며, 여기에는 안전 메커니즘을 우회하기 위해 LLM을 조작하는 것이 포함됩니다. 인코딩 방법에 대한 자세한 내용은 조사 논문의 섹션 3.2 및 부록 A.1.2를 참조하십시오.
필터링
pip install selective-context
python -m spacy download en_core_web_sm
sc = SelectiveContext(model_type = ‘gpt-2’, lang = ‘en’)
토큰 수준 감소
context, reduced_content = sc(text, reduce_ratio = 0.5, reduce_level = ‘sent’)
from openai import OpenAI client = OpenAI(api_key = key) completion = client.chat.completions.create( model = “gpt-3.5-turbo-0125”, messages = [ {“role”: “user”, “content”: f”Summarize the following paragraph:\n {text}”} ] )
[Prompt compression is useful in scenarios such as advanced prompt engineering techniques and retrieval-augmented generation pipelines to reduce token counts and costs while preserving effectiveness and context. However, it is not a universal solution and should be used judiciously, as excessive compression can lead to a loss of important details. It is important to strike a balance between reducing size and maintaining the prompt's meaning.]압축 레벨
[When Should Prompt CompProm compression particularly following Advanced prompt engineering Techniques like chainofthought prompting while highly lengthy prompts reach thousands tokensThis increases processing costs and may exceed token limits of certain modelsProm compression mit these token count while prompt effectivenessRetri-au generationRAG pipelines R combine information retrieval text specialized chat contextual understandingThese pipelines frequently involve providing extensive conversation histories retrieved as prompts leading high token counts increased expensesProm compression essential such essential context while costsApplic prompt compression It prompt universal judFor instance assistant models like ChatGPT designed convers contexts benefit aggressive prompt compressionThese models often do charge per token integrated chat summar memory features conversation history effectively compression redundantIt even working models charge per token excessive compression could nuance importantSt reducing size maintaining prompt’s meaning is]
정확도
토큰 레벨
129
183
이 연습은 특정 응용 프로그램을 기반으로 압축 수준을 신중하게 선택해야하며 프롬프트에서 특정 세부 사항을 유지하는 중요성을 신중하게 선택해야합니다.
프롬프트 엔지니어링 이해
프롬프트 압축이란 무엇인가, 중요한 이유는 무엇입니까? 프롬프트 압축 기술을 향상시키기 위해 어떤 리소스를 사용할 수 있습니까? 프롬프트 압축을 사용할 때 윤리적 고려 사항이 있습니까? 프롬프트 압축 FAQS
프롬프트 압축은 유산의 품질과 관련성을 유지하면서 길이를 줄임으로써 대형 언어 모델 (LLMS)에 주어진 입력을 최적화하는 데 사용되는 기술입니다. 신속한 압축을 구현할 때 일반적인 과제는 무엇입니까?
일반적인 과제에는 압축과 보존의 균형을 유지하고 다양한 유형의 입력 데이터를 보장하는 것이 포함됩니다. 또한 기계 학습 기반 및 하이브리드 접근 방식을 구현하는 것은 리소스 집약적이고 복잡 할 수 있습니다. 예, 윤리적 고려 사항에는 압축이 우연히 편견을 불러 일으키거나 유해한 유해한 정보를 생략하지 않도록하는 것이 포함됩니다. 또한 신속한 압축 기술은 모델을 실수로 탈옥하여 예측할 수 없을 정도로 행동하거나 부적절한 컨텐츠를 생성 할 수 있습니다. 특히 의료, 금융 또는 법률 자문과 같은 민감한 응용 분야에서 모델의 성능 및 출력에 대한 신속한 압축 효과를 모니터링하는 것이 중요합니다.
위 내용은 프롬프트 압축 : 파이썬 예제가있는 안내서의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!