2024/03/28 5

[GPT] Caching

캐싱을 사용하면 언어모델의 응답을 저장할 수 있음 이후 동일 질문을 받을경우 언어모델에 질의를 하지 않고 캐싱된 답변을 가져옴 set_llm_cache 새 LLM 캐시 설정, 이전 값 덮어쓰기(있는 경우) 캐시 종류 InMemoryCache: 메모리를 이용하여 캐시를 저장. 서버 재실행시 캐싱된 내용이 사라짐 SQLite Cache: SQLite cache를 이용하여 캐시를 저장 그외에도 여러가지의 캐시가 있음 https://python.langchain.com/docs/integrations/llms/llm_caching#in-memory-cache LLM Caching integrations | 🦜️🔗 Langchain This notebook covers how to cache results of ..

python 2024.03.28

[GPT] PipelinePromptTemplate

여러개의 prompt를 하나로 합쳐주는 기능 prompt를 재사용하는데 유용함 pipeline prompt 는 크게 두부분으로 구성 Final prompt: 최종 프롬프트 반환 Pipeline prompts: 문자열 이름과 프롬프트 템플릿으로 구성된 튜플 리스트 각 prompt template은 이미 format이 완료된 상태이며 동일 변수명으로 prompt template 에 전달된다. [결과값] "You are impersonating Elon Musk.\n\nHere's an example of an interaction:\n\nQ: What's your favorite car?\nA: Tesla\n\nNow, do this for real!\n\nQ: What's your favorite soci..

python 2024.03.28

[GPT] LengthBasedExampleSelector

LengthBasedExampleSelector 텍스트 길이를 기준으로 FewShotPromptTemplate 사용시 제시되는 example 들 중에 원하는 example을 선택할수 있음 [결과] 'Human: What do you know about France?\nAI: \n Here is what I know:\n Capital: Paris\n Language: French\n Food: Wine and Cheese\n Currency: Euro\n \n\nHuman: What do you know about Italy?\nAI: \n I know this:\n Capital: Rome\n Language: Italian\n Food: Pizza and Pasta\n Currency: Euro\n ..

python 2024.03.28