Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Time to first token

From noriwiki


개요

Time to first token(TTFT)는 LLM의 성능을 평가하는 지표로, 사용자가 프롬프트를 입력한 후 첫 번째 토큰이 생성될 때까지 걸리는 시간을 의미한다. LLM의 Latency를 측정하는 데 사용된다.

TTFT는 LLM이 "첫 반응을 제공하는 속도"를 나타내며, 사용자 경험에 큰 영향을 미친다.

import time  
import openai  

start_time = time.time()  
response = openai.ChatCompletion.create(model="gpt-4", messages=[{"role": "user", "content": "Hello!"}], stream=True)  

for chunk in response:  
    if chunk["choices"][0]["delta"]:  
        first_token_time = time.time() - start_time  
        print(f"TTFT: {first_token_time:.3f} seconds")  
        break
Contents