sample metrics
This commit is contained in:
parent
c490416189
commit
cca61181cb
2 changed files with 13 additions and 0 deletions
11
api/types.go
11
api/types.go
|
@ -98,6 +98,8 @@ type GenerateResponse struct {
|
||||||
|
|
||||||
TotalDuration time.Duration `json:"total_duration,omitempty"`
|
TotalDuration time.Duration `json:"total_duration,omitempty"`
|
||||||
LoadDuration time.Duration `json:"load_duration,omitempty"`
|
LoadDuration time.Duration `json:"load_duration,omitempty"`
|
||||||
|
SampleCount int `json:"sample_count,omitempty"`
|
||||||
|
SampleDuration time.Duration `json:"sample_duration,omitempty"`
|
||||||
PromptEvalCount int `json:"prompt_eval_count,omitempty"`
|
PromptEvalCount int `json:"prompt_eval_count,omitempty"`
|
||||||
PromptEvalDuration time.Duration `json:"prompt_eval_duration,omitempty"`
|
PromptEvalDuration time.Duration `json:"prompt_eval_duration,omitempty"`
|
||||||
EvalCount int `json:"eval_count,omitempty"`
|
EvalCount int `json:"eval_count,omitempty"`
|
||||||
|
@ -113,6 +115,15 @@ func (r *GenerateResponse) Summary() {
|
||||||
fmt.Fprintf(os.Stderr, "load duration: %v\n", r.LoadDuration)
|
fmt.Fprintf(os.Stderr, "load duration: %v\n", r.LoadDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.SampleCount > 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "sample count: %d token(s)\n", r.SampleCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.SampleDuration > 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "sample duration: %s\n", r.SampleDuration)
|
||||||
|
fmt.Fprintf(os.Stderr, "sample rate: %.2f tokens/s\n", float64(r.SampleCount)/r.SampleDuration.Seconds())
|
||||||
|
}
|
||||||
|
|
||||||
if r.PromptEvalCount > 0 {
|
if r.PromptEvalCount > 0 {
|
||||||
fmt.Fprintf(os.Stderr, "prompt eval count: %d token(s)\n", r.PromptEvalCount)
|
fmt.Fprintf(os.Stderr, "prompt eval count: %d token(s)\n", r.PromptEvalCount)
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,8 @@ func (llm *LLM) Predict(ctx []int, prompt string, fn func(api.GenerateResponse))
|
||||||
fn(api.GenerateResponse{
|
fn(api.GenerateResponse{
|
||||||
Done: true,
|
Done: true,
|
||||||
Context: last,
|
Context: last,
|
||||||
|
SampleCount: int(timings.n_sample),
|
||||||
|
SampleDuration: parseDurationMs(float64(timings.t_sample_ms)),
|
||||||
PromptEvalCount: int(timings.n_p_eval),
|
PromptEvalCount: int(timings.n_p_eval),
|
||||||
PromptEvalDuration: parseDurationMs(float64(timings.t_p_eval_ms)),
|
PromptEvalDuration: parseDurationMs(float64(timings.t_p_eval_ms)),
|
||||||
EvalCount: int(timings.n_eval),
|
EvalCount: int(timings.n_eval),
|
||||||
|
|
Loading…
Reference in a new issue