LLM 벤치마크 - LM Harness, FastEval, Flask

LLM 벤치마크 - LM Harness, FastEval, Flask

LiteLLM으로 LLM을 벤치마크하는 여러 방법을 알아봐요.

LM Harness Benchmarks

TGI와 함께 litellm proxy의 /completions 엔드포인트를 사용해 LLM을 20배 더 빠르게 평가해 보세요. 이 튜토리얼은 lm-evaluation-harness의 big-refactor 브랜치를 사용한다고 가정합니다.

참고: LM Harness는 openai 1.0.0+로 업데이트하지 않았으므로 lm harness를 venv에서 실행할 거예요.

1단계: 로컬 proxy 시작 지원되는 모델은 여기를 참고하세요.

$ litellm --model huggingface/bigcode/starcoder

커스텀 api base 사용:

$ export HUGGINGFACE_API_KEY=my-api-key #[OPTIONAL]$ litellm --model huggingface/tinyllama --api_base https://k58ory32yinf1ly0.us-east-1.aws.endpoints.huggingface.cloud

OpenAI 호환 엔드포인트가 http://0.0.0.0:4000에 있습니다.

2단계: LM Harness용 Virtual Env 생성 + OpenAI 0.28.1 사용 이제 openai==0.28.1이 설치된 새 virtual env로 lm harness를 실행할 거예요.

python3 -m venv lmharness source lmharness/bin/activate

venv에 openai==0.28.01을 pip install 합니다.

uv add openai==0.28.01

3단계: OpenAI API Base & Key 설정

$ export OPENAI_BASE_URL=http://0.0.0.0:4000

LM Harness는 벤치마크 실행을 위해 OpenAI API key OPENAI_API_SECRET_KEY를 설정해야 해요.

export OPENAI_API_SECRET_KEY=anything

4단계: LM-Eval-Harness 실행

cd lm-evaluation-harness

venv에 lm harness 의존성을 추가하세요.

uv sync
python3 -m lm_eval \
  --model openai-completions \
  --model_args engine=davinci \
  --task crows_pairs_english_age

FastEval

1단계: 로컬 proxy 시작 지원되는 모델은 여기를 참고하세요.

$ litellm --model huggingface/bigcode/starcoder

2단계: OpenAI API Base & Key 설정

$ export OPENAI_BASE_URL=http://0.0.0.0:4000

proxy가 자격 증명을 가지므로 이 값을 아무거나로 설정하세요.

export OPENAI_API_KEY=anything

3단계 FastEval로 실행

FastEval 클론

# Clone this repository, make it the current working directorygit clone --depth 1 https://github.com/FastEval/FastEval.gitcd FastEval

FastEval에 API Base 설정

FastEval에서 OPENAI_BASE_URL을 설정하기 위해 2줄 코드 변경을 만드세요.

https://github.com/FastEval/FastEval/pull/90/files

try:    api_base = os.environ["OPENAI_BASE_URL"] #changed: read api base from .env    if api_base == None:        api_base = "https://api.openai.com/v1"    response = await self.reply_two_attempts_with_different_max_new_tokens(        conversation=conversation,        api_base=api_base, # #changed: pass api_base        api_key=os.environ["OPENAI_API_KEY"],        temperature=temperature,        max_new_tokens=max_new_tokens,

FastEval 실행 실행하려는 벤치마크를 -b로 설정하세요. 가능한 값은 mt-bench, human-eval-plus, ds1000, cot, cot/gsm8k, cot/math, cot/bbh, cot/mmlu, custom-test-data예요.

LiteLLM이 OpenAI 호환 proxy를 제공하므로 -t-m은 변경할 필요가 없어요. -t는 openai로 유지됩니다. -m은 gpt-3.5로 유지됩니다.

./fasteval -b human-eval-plus -t openai -m gpt-3.5-turbo

FLASK - Fine-grained Language Model Evaluation

litellm을 사용해 어떤 LLM이든 FLASK에서 평가해 보세요: https://github.com/kaistAI/FLASK

1단계: 로컬 proxy 시작

$ litellm --model huggingface/bigcode/starcoder

2단계: OpenAI API Base & Key 설정

$ export OPENAI_BASE_URL=http://0.0.0.0:4000

3단계 FLASK로 실행

git clone https://github.com/kaistAI/FLASK
cd FLASK/gpt_review

eval 실행:

python gpt4_eval.py -q '../evaluation_set/flask_evaluation.jsonl'

디버깅

proxy에 테스트 요청 보내기

이 명령은 proxy 서버에 테스트 Completion, ChatCompletion 요청을 보냅니다.

litellm --test

더 알아보기 (Learn more)