|
|
||
|---|---|---|
| .. | ||
| tests | ||
| .gitkeep | ||
| README.md | ||
| eval.c | ||
| eval.h | ||
README.md
eval/
C implementation of LLM evaluation and benchmarking.
Python counterpart
lm-eval-harness - https://github.com/EleutherAI/lm-evaluation-harness
Why lm-eval-harness?
lm-eval-harness is the standard for evaluating language models:
- Standardized benchmarks - MMLU, HellaSwag, ARC, TruthfulQA, etc.
- Reproducible results - Consistent evaluation methodology
- Multiple metrics - Accuracy, perplexity, F1, exact match
- Few-shot evaluation - Test with N examples in context
Alternatives (HELM, OpenAI evals) cover different benchmark suites.
Scope
This module implements:
- Core metrics - Accuracy, perplexity, exact match
- Multiple choice - For benchmarks like MMLU, HellaSwag
- Generation eval - For open-ended tasks
- Few-shot prompting - Construct prompts with examples
- Common benchmarks - MMLU, HellaSwag, ARC, Winogrande
Getting Started
Dependencies
- tensor/ module (for model inference)
- tokenizer/ module (for text processing)
- data/ module (for loading benchmark data)
Key Files to Study
From lm-eval-harness:
lm_eval/tasks/- Task definitionslm_eval/api/model.py- Model interfacelm_eval/evaluator.py- Evaluation loop
Core API
// Initialize evaluator with model
fe_evaluator* fe_new(tm_model* model, ft_tokenizer* tokenizer);
// Run specific benchmark
fe_result* fe_run_task(fe_evaluator* e, const char* task, int num_fewshot);
// Available tasks
const char** fe_list_tasks(void);
// Results
typedef struct {
const char* task;
float accuracy;
float stderr;
int num_samples;
} fe_result;
void fe_print_result(fe_result* r);
void fe_save_results(fe_result** results, int n, const char* path);
// Metrics
float fe_accuracy(int* predictions, int* labels, int n);
float fe_perplexity(tm_model* model, const char** texts, int n);
float fe_exact_match(const char** predictions, const char** references, int n);
// Multiple choice evaluation
int fe_loglikelihood_choice(tm_model* model, const char* context,
const char** choices, int num_choices);
Benchmark Format
Tasks are defined as JSON:
{
"task": "hellaswag",
"type": "multiple_choice",
"dataset": "hellaswag",
"prompt_template": "{context}",
"choices_key": "endings",
"label_key": "label",
"num_fewshot": 10
}
Implementation Order
- Core metrics (accuracy, perplexity)
- Multiple choice evaluation
- Few-shot prompt construction
- HellaSwag benchmark
- MMLU benchmark
- ARC benchmark
- Results reporting