Definition Understanding
A project to evaluate how well Large Language Models (LLMs) understand word definitions.
Overview
This project tests LLMs' ability to predict words based on their definitions. The methodology involves:
- Curating a dataset of words and their definitions from dictionary sources
- Presenting definitions to LLMs and asking them to predict the corresponding words
- Evaluating performance using various metrics
- Accounting for synonyms in the evaluation process
Model Performance Comparison
Figure: Performance comparison of evaluated language models on the definition understanding task.
Conclusions
- Claude-3-7-Sonnet and gpt-4.1 achieve the highest exact and fuzzy accuracy, with Claude-3-7-Sonnet slightly outperforming gpt-4.1 overall.
- gpt-4.1-mini and gpt-4.1-nano show lower performance across all metrics, indicating the benefits of larger or more advanced models for this task.
- Fuzzy and synonym-based metrics are notably higher than exact accuracy, highlighting the importance of considering near-misses and alternative valid answers when evaluating language models on definition understanding tasks.
- The results suggest that both model size and architecture play important roles in accurately interpreting and predicting word definitions.
Project Structure
data/: Contains raw and processed dictionary datasets- Download the medical terms dataset from here
src/: Source code for the projectdata_processing/: Scripts for data acquisition and preprocessingevaluation/: Modules for evaluating LLM performancemodels/: Interfaces to different LLMs
notebooks/: Jupyter notebooks for analysis and visualizationtests/: Unit tests
Getting Started
-
Set up environment variables:
- Copy
.env.exampleto.envin the project root:cp .env.example .env # On Windows (PowerShell): copy .env.example .env - Edit
.envto fill in your HuggingFace token and any other required variables.
- Copy
-
Set up the environment: Install uv if not already installed:
pip install uv
Create and activate a virtual environment:
uv venv
On windows:
venv\Scripts\activate
On linux:
sudo venv/bin/activate
Install dependencies:
uv sync
Alternatively you can use pip:
pip install -e .
-
Run the data collection script:
python src/data_processing/collect_dictionary.py
-
Evaluate an LLM (all available arguments):
python src/evaluation/evaluate_model.py \ --model [MODEL_NAME] \ --judgellm_model_name [JUDGE_MODEL_NAME] \ --dataset [DATASET_PATH] \ --output-dir [OUTPUT_DIRECTORY] \ --num-samples [NUM_SAMPLES] \ --verbose \ --is_local [True|False]Argument descriptions:
--model: Name of the model to evaluate (e.g.,meta-llama/Llama-3.2-3B-Instruct-Turbo)--judgellm_model_name: Name of the JudgeLLM model (default:gpt-4o-mini)--dataset: Path to the dataset (default:data/processed_dictionary.csv)--output-dir: Directory to save evaluation results (default:results)--num-samples: Number of samples to evaluate (default: all)--verbose: Print detailed information (flag)--is_local: Use a local inference engine (default: False)
-
Run all benchmarks (evaluate all models in the benchmark list):
python run_benchmarks.py
License
MIT