DeepSeek API
🇰🇷 Korea
  • 🇺🇸 English
  • 🇯🇵 Japanese
  • 🇰🇷 Korea
  • 🇵🇹 Portuguese
  1. API 가이드
DeepSeek API
🇰🇷 Korea
  • 🇺🇸 English
  • 🇯🇵 Japanese
  • 🇰🇷 Korea
  • 🇵🇹 Portuguese
  • 빨리 시작하십시오
    • 첫 번째 API 호출
    • 모델 및 가격
    • 온도 매개 변수
    • 토큰 및 토큰 사용
    • 한계
    • 오류 코드
  • API 참조
    • 소개
    • 채팅 완료를 만듭니다
      POST
    • FIM 완료 생성 (Beta)
      POST
    • 모델을 나열합니다
      GET
    • 사용자 균형을 얻으십시오
      GET
  • API 가이드
    • 추론 모델 (Deepseek Reautoner)
    • 여러 라운드의 대화
    • 채팅 접두사 완료 (Beta)
    • FIM 완료 (Beta)
    • JSON 출력
    • 기능 호출
    • 컨텍스트 캐싱
  • FAQ
    • FAQ
  1. API 가이드

컨텍스트 캐싱

디스크 기술에 대한 DeepSeek API 컨텍스트 캐싱은 모든 사용자에게 기본적으로 활성화되어 코드를 수정할 필요없이 이익을 얻을 수 있습니다.
각 사용자 요청은 하드 디스크 캐시의 구성을 트리거합니다. 후속 요청이 이전 요청과 겹치는 접두사가있는 경우, 겹치는 부분은 캐시에서만 가져 오며 "캐시 히트"로 계산됩니다.
참고 : 두 요청 사이에 반복 접두사 부분 만 "캐시 히트"를 트리거 할 수 있습니다. 자세한 내용은 아래 예제를 참조하십시오.

예 1 : 긴 텍스트 Q & A#

첫 번째 요청
messages: [
    {"role": "system", "content": "You are an experienced financial report analyst..."}
    {"role": "user", "content": "<financial report content>\n\nPlease summarize the key information of this financial report."}
]
두 번째 요청
messages: [
    {"role": "system", "content": "You are an experienced financial report analyst..."}
    {"role": "user", "content": "<financial report content>\n\nPlease analyze the profitability of this financial report."}
]
위의 예에서, 두 요청은 동일한 접두사 를 가지며, 이는 user 메시지에서 system 메시지 + <financial report content> 입니다. 두 번째 요청 에서이 접두사 부분은 "캐시 히트"로 계산됩니다.

예제 2 : 다소 라운드 대화#

첫 번째 요청
messages: [
    {"role": "system", "content": "You are a helpful assistant"},
    {"role": "user", "content": "What is the capital of China?"}
]
두 번째 요청
messages: [
    {"role": "system", "content": "You are a helpful assistant"},
    {"role": "user", "content": "What is the capital of China?"},
    {"role": "assistant", "content": "The capital of China is Beijing."},
    {"role": "user", "content": "What is the capital of the United States?"}
]
이 예에서 두 번째 요청은 첫 번째 요청에서 초기 system 메시지와 user 메시지를 재사용 할 수 있으며, 이는 "캐시 히트"로 계산됩니다.

예 3 : 소수의 샷 학습 사용#

실제 응용 프로그램에서 사용자는 소수의 학습을 통해 모델의 출력 성능을 향상시킬 수 있습니다. 소수의 학습에는 모델이 특정 패턴을 배울 수 있도록 요청에 몇 가지 예제를 제공하는 것이 포함됩니다. 소수의 샷은 일반적으로 동일한 컨텍스트 접두사를 제공하기 때문에 컨텍스트 캐싱의 지원으로 소수의 비용이 크게 줄어 듭니다.
첫 번째 요청
messages: [    
    {"role": "system", "content": "You are a history expert. The user will provide a series of questions, and your answers should be concise and start with `Answer:`"},
    {"role": "user", "content": "In what year did Qin Shi Huang unify the six states?"},
    {"role": "assistant", "content": "Answer: 221 BC"},
    {"role": "user", "content": "Who was the founder of the Han Dynasty?"},
    {"role": "assistant", "content": "Answer: Liu Bang"},
    {"role": "user", "content": "Who was the last emperor of the Tang Dynasty?"},
    {"role": "assistant", "content": "Answer: Li Zhu"},
    {"role": "user", "content": "Who was the founding emperor of the Ming Dynasty?"},
    {"role": "assistant", "content": "Answer: Zhu Yuanzhang"},
    {"role": "user", "content": "Who was the founding emperor of the Qing Dynasty?"}
]
두 번째 요청
messages: [    
    {"role": "system", "content": "You are a history expert. The user will provide a series of questions, and your answers should be concise and start with `Answer:`"},
    {"role": "user", "content": "In what year did Qin Shi Huang unify the six states?"},
    {"role": "assistant", "content": "Answer: 221 BC"},
    {"role": "user", "content": "Who was the founder of the Han Dynasty?"},
    {"role": "assistant", "content": "Answer: Liu Bang"},
    {"role": "user", "content": "Who was the last emperor of the Tang Dynasty?"},
    {"role": "assistant", "content": "Answer: Li Zhu"},
    {"role": "user", "content": "Who was the founding emperor of the Ming Dynasty?"},
    {"role": "assistant", "content": "Answer: Zhu Yuanzhang"},
    {"role": "user", "content": "When did the Shang Dynasty fall?"},        
]
이 예에서는 4 샷이 사용됩니다. 두 요청의 유일한 차이점은 마지막 질문입니다. 두 번째 요청은 첫 번째 요청에서 첫 4 라운드 대화의 내용을 재사용 할 수 있으며, 이는 "캐시 히트"로 간주됩니다.

캐시 적중 상태 확인#

DeepSeek API의 응답으로, 우리는 usage 섹션에 두 개의 필드를 추가하여 요청의 캐시 적중 상태를 반영했습니다.
1.
Prompt_cache_hit_tokens :이 요청의 입력에있는 토큰 수는 캐시에 맞았습니다 (백만 마리의 토큰 당 0.1 위안).
2.
Prompt_cache_miss_tokens :이 요청의 입력에있는 토큰 수는 캐시 히트 (백만 개의 토큰 당 1 위안)를 초래하지 않습니다.

하드 디스크 캐시 및 출력 임의성#

하드 디스크 캐시는 사용자 입력의 접두사 부분 만 일치합니다. 출력은 여전히 ​​계산 및 추론을 통해 생성되며 온도와 같은 매개 변수에 의해 영향을 받고 임의성을 도입합니다.

추가 메모#

1.
캐시 시스템은 64 개의 토큰을 저장 장치로 사용합니다. 64 개 미만의 토큰은 캐시되지 않습니다.
2.
캐시 시스템은 "최고의 효과"기준으로 작동하며 100% 캐시 적중률을 보장하지 않습니다.
3.
캐시 구성은 몇 초가 걸립니다. 캐시가 더 이상 사용되지 않으면 보통 몇 시간 내지 며칠 내에 자동으로 지워집니다.
Previous
기능 호출
Next
FAQ
Built with