Skip to main content

ParsBench

ParsBench provides toolkits for benchmarking Large Language Models (LLMs) based on the Persian language. It includes various tasks for evaluating LLMs on different topics, benchmarking tools to compare multiple models and rank them, and an easy, fully customizable API for developers to create custom models, tasks, scores, and benchmarks.

Key Features

  • Variety of Tasks: Evaluate LLMs across various topics.
  • Benchmarking Tools: Compare and rank multiple models.
  • Customizable API: Create custom models, tasks, scores, and benchmarks with ease.

Motivation

I was trying to fine-tune an open-source LLM for the Persian language. I needed some evaluation to test the performance and utility of my LLM. It leads me to research and find this paper. It's great work that they prepared some datasets and evaluation methods to test on ChatGPT. They even shared their code in this repository.

So, I thought that I should build a handy framework that includes various tasks and datasets for evaluating LLMs based on the Persian language. I used some parts of their work (Datasets, Metrics, Basic prompt templates) in this library.

Installation

Install Math Equivalence package manually:

pip install git+https://github.com/hendrycks/math.git

Install ParsBench using pip:

pip install parsbench

Usage

Evaluating a PreTrained Model

Load the pre-trained model and tokenizer from the HuggingFace and then, evaluate the model using the PersianMath task:

from transformers import AutoModelForCausalLM, AutoTokenizer

from parsbench.models import PreTrainedTransformerModel
from parsbench.tasks import PersianMath

model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen2-72B-Instruct",
    torch_dtype="auto",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-72B-Instruct")

tf_model = PreTrainedTransformerModel(model=model, tokenizer=tokenizer)

with PersianMath() as task:
    results = task.evaluate(tf_model)

Benchmarking Multiple Models with Multiple Tasks

For example, we run our local models using Ollama:

ollama run qwen2
ollama run aya

Then we benchmark those models using the ParsBench.

from parsbench.benchmarks import CustomBenchmark
from parsbench.models import OpenAIModel
from parsbench.tasks import ParsiNLUMultipleChoice, PersianMath, ParsiNLUReadingComprehension

qwen2_model = OpenAIModel(
    api_base_url="http://localhost:11434/v1/",
    api_secret_key="ollama",
    model="qwen2:latest",
)
aya_model = OpenAIModel(
    api_base_url="http://localhost:11434/v1/",
    api_secret_key="ollama",
    model="aya:latest",
)

benchmark = CustomBenchmark(
    models=[qwen2_model, aya_model],
    tasks=[
        ParsiNLUMultipleChoice,
        ParsiNLUReadingComprehension,
        PersianMath,
    ],
)
result = benchmark.run(
    prompt_lang="fa",
    prompt_shots=[0, 3],
    n_first=100,
    sort_by_score=True,
)
result.show_radar_plot()

Benchmark Bar Plot

Available Tasks

Task Name Score Name Dataset
ParsiNLU Sentiment Analysis Exact Match (F1) ParsiNLU
ParsiNLU Entailment Exact Match (F1) ParsiNLU
ParsiNLU Machine Translation En -> Fa Bleu ParsiNLU
ParsiNLU Machine Translation Fa -> En Bleu ParsiNLU
ParsiNLU Multiple Choice Exact Match (Accuracy) ParsiNLU
ParsiNLU Reading Comprehension Common Tokens (F1) ParsiNLU
Persian NER NER Exact Match (F1) PersianNER
Persian Math Math Equivalence (Accuracy) Source
ConjNLI Entailment Exact Match (F1) Source
Persian MMLU (Khayyam Challenge) Exact Match (Accuracy) Khayyam Challenge
FarsTail Entailment Exact Match (F1) FarsTail
Persian News Summary Rouge PNSummary
XL-Sum Rouge XLSum

You can import the class of above tasks from parsbench.tasks and use it for evaluating your model.

Example Notebooks

  • Benchmark Aya models: aya
  • Benchmark Ava models: ava
  • Benchmark Dorna models: dorna
  • Benchmark MaralGPT models: maralgpt

Sponsors

Here are the names of companies/people who helped us to keep maintaining this project. If you want to donate this project, see this page.

  • AvalAI: They gave us free OpenAI API credit several times in their "AvalAward" program. It helped us for doing R&D and benchmarking GPT models.
  • Basalam: They voluntarily helped us to run the benchmarks on open-weight models and build the ParsBench Leaderboard.

Contributing

Contributions are welcome! Please refer to the contribution guidelines for more information on how to contribute.

Citation

If you use ParsBench in your research, please cite it as follows:

@software{parsbench2025,
  author = {Shahriar Shariati Motlagh},
  title = {ParsBench: A Toolkit for Benchmarking Persian Language Models},
  url = {https://github.com/ParsBench/ParsBench},
  year = {2025},
}

Or in text format:

Shariati Motlagh, S. (2025). ParsBench: A Toolkit for Benchmarking Persian Language Models. GitHub repository: https://github.com/ParsBench/ParsBench

License

ParsBench is distributed under the Apache-2.0 license.

Contact Information

For support or questions, please contact: shahriarshm81@gmail.com Feel free to let me know if there are any additional details or changes you'd like to make!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parsbench-0.2.0.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parsbench-0.2.0-py3-none-any.whl (71.7 kB view details)

Uploaded Python 3

File details

Details for the file parsbench-0.2.0.tar.gz.

File metadata

  • Download URL: parsbench-0.2.0.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.4 Darwin/25.5.0

File hashes

Hashes for parsbench-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8308f95fc1fcc65ed23db6228be5ce0427dbb43e13fdb371a8b97df33982d34f
MD5 1c5a96422c9922a2b2a79115d16b08f7
BLAKE2b-256 1949e9517e4e3946941f45c8eb1c5c84e2343fe28b5487574d62b81614f0f10a

See more details on using hashes here.

File details

Details for the file parsbench-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: parsbench-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 71.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.4 Darwin/25.5.0

File hashes

Hashes for parsbench-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 138893855d023097557f6e6895135e5947c7875c6915dc447ca16f3bb831cab9
MD5 9e7f5a1c734d575897a7a8f220b09b97
BLAKE2b-256 851847d80bdf4c5515e801358bdd16b7fa0f88ebafb9ca4a1a2c5058080d475d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page