bangla-ai-eval 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bangla_ai_eval-0.1.0/.gitignore +12 -0
- bangla_ai_eval-0.1.0/CONTRIBUTING.md +68 -0
- bangla_ai_eval-0.1.0/LICENSE +21 -0
- bangla_ai_eval-0.1.0/PKG-INFO +127 -0
- bangla_ai_eval-0.1.0/README.md +103 -0
- bangla_ai_eval-0.1.0/bangla_eval/__init__.py +3 -0
- bangla_ai_eval-0.1.0/bangla_eval/__main__.py +152 -0
- bangla_ai_eval-0.1.0/bangla_eval/cases.py +117 -0
- bangla_ai_eval-0.1.0/bangla_eval/export.py +41 -0
- bangla_ai_eval-0.1.0/bangla_eval/normalize.py +50 -0
- bangla_ai_eval-0.1.0/bangla_eval/providers.py +135 -0
- bangla_ai_eval-0.1.0/bangla_eval/run.py +115 -0
- bangla_ai_eval-0.1.0/bangla_eval/scoring.py +60 -0
- bangla_ai_eval-0.1.0/cases/bangla-calendar.yaml +111 -0
- bangla_ai_eval-0.1.0/cases/banglish.yaml +61 -0
- bangla_ai_eval-0.1.0/cases/bd-facts.yaml +134 -0
- bangla_ai_eval-0.1.0/cases/dialect.yaml +52 -0
- bangla_ai_eval-0.1.0/cases/digits.yaml +64 -0
- bangla_ai_eval-0.1.0/cases/grammar.yaml +67 -0
- bangla_ai_eval-0.1.0/cases/number-words.yaml +167 -0
- bangla_ai_eval-0.1.0/cases/proverbs.yaml +70 -0
- bangla_ai_eval-0.1.0/cases/riddles.yaml +27 -0
- bangla_ai_eval-0.1.0/cases/taka-format.yaml +54 -0
- bangla_ai_eval-0.1.0/pyproject.toml +48 -0
- bangla_ai_eval-0.1.0/tests/test_cases_and_run.py +94 -0
- bangla_ai_eval-0.1.0/tests/test_scoring.py +82 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Contributing / অবদান রাখুন
|
|
2
|
+
|
|
3
|
+
## বাংলায়
|
|
4
|
+
|
|
5
|
+
এই প্রজেক্টে সবচেয়ে বড় অবদান হলো **একটা ভালো প্রশ্ন**। এমন প্রশ্ন যেটা যেকোনো বাংলাদেশি সহজেই পারে, কিন্তু AI ভুল করতে পারে। কোড জানার দরকার নেই।
|
|
6
|
+
|
|
7
|
+
### একটা প্রশ্ন যোগ করার ধাপ
|
|
8
|
+
1. [`cases/`](cases) ফোল্ডারে বিষয় অনুযায়ী ফাইল খুলুন (যেমন `bd-facts.yaml`)।
|
|
9
|
+
2. উপরের ডানে পেন্সিল (✏️ Edit) আইকনে ক্লিক করুন। GitHub নিজেই আপনার জন্য একটা কপি বানিয়ে নেবে।
|
|
10
|
+
3. ফাইলের একদম শেষে নিচের মতো করে আপনার প্রশ্ন লিখুন:
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
- id: bd-facts-021 # বিষয়ের নাম + পরের নম্বর
|
|
14
|
+
prompt: বাংলাদেশের জাতীয় মাছের নাম কী?
|
|
15
|
+
answer: ইলিশ
|
|
16
|
+
accept: # অন্য যেসব বানানও সঠিক (না থাকলে এই অংশ বাদ দিন)
|
|
17
|
+
- ইলিশ মাছ
|
|
18
|
+
author: your-github-username
|
|
19
|
+
verified: false
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
4. নিচে **Commit changes** → **Propose changes** → **Create pull request** চাপুন।
|
|
23
|
+
5. স্বয়ংক্রিয় পরীক্ষা (CI) ফরম্যাট ঠিক আছে কিনা দেখবে। তারপর একজন রিভিউয়ার দেখে merge করবেন।
|
|
24
|
+
|
|
25
|
+
### ভালো প্রশ্নের নিয়ম
|
|
26
|
+
- **উত্তর একটাই, আর নিশ্চিত।** মতামত বা "নির্ভর করে" ধরনের প্রশ্ন না।
|
|
27
|
+
- **রাজনীতি, ধর্মীয় বিতর্ক বা কোনো ব্যক্তিকে নিয়ে বিতর্কিত প্রশ্ন না।**
|
|
28
|
+
- **যে তথ্য বদলায় না।** "এখন মন্ত্রী কে" ধরনের প্রশ্ন এক বছরে পুরনো হয়ে যায়।
|
|
29
|
+
- একই উত্তরের সব প্রচলিত বানান `accept` এ দিন।
|
|
30
|
+
- AI দিয়ে প্রশ্ন বানাতে পারেন, কিন্তু **প্রতিটা উত্তর নিজে যাচাই করে** তবেই দিন। যাচাই না করা প্রশ্ন এই benchmark এর মূল্য নষ্ট করে।
|
|
31
|
+
- একটা PR এ 5–10টা প্রশ্ন সবচেয়ে ভালো।
|
|
32
|
+
|
|
33
|
+
### রিভিউ
|
|
34
|
+
অন্যের প্রশ্ন যাচাই করাও বড় অবদান। কোনো উত্তর ভুল বা অস্পষ্ট দেখলে Issue খুলুন। আর আপনি নিশ্চিত হলে PR দিয়ে `verified: true` করুন।
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## In English
|
|
39
|
+
|
|
40
|
+
The most valuable contribution is **a good question**: one any Bangladeshi gets right, and a model might not. No coding needed.
|
|
41
|
+
|
|
42
|
+
1. Open the matching file in [`cases/`](cases) and click the ✏️ **Edit** icon (GitHub forks for you).
|
|
43
|
+
2. Add your case at the end, using the YAML shape above.
|
|
44
|
+
3. **Commit changes → Propose changes → Create pull request.** CI checks the format, then a reviewer merges it.
|
|
45
|
+
|
|
46
|
+
**Rules:** one clear, stable answer · no politics, religious disputes or claims about individuals · list every accepted spelling under `accept` · if AI helped draft a case, **verify the answer yourself** · 5–10 cases per PR is ideal.
|
|
47
|
+
|
|
48
|
+
**Code contributions** (new providers, scoring modes, reports) are welcome too:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install PyYAML pytest
|
|
52
|
+
python -m bangla_eval validate
|
|
53
|
+
python -m pytest -q
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Case fields
|
|
57
|
+
| Field | Required | Meaning |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| `id` | ✓ | `<category>-<3-digit number>`, unique |
|
|
60
|
+
| `prompt` | ✓ | The question, in Bangla |
|
|
61
|
+
| `answer` | ✓* | Canonical answer (*not needed for `match: regex`) |
|
|
62
|
+
| `accept` | | Other correct spellings |
|
|
63
|
+
| `match` | | `exact` (default), `contains`, `regex` |
|
|
64
|
+
| `pattern` | | Regex for `match: regex` |
|
|
65
|
+
| `fold_digits` | | `true` if ১৬ and 16 both count as correct |
|
|
66
|
+
| `note` | | Anything a reviewer should know |
|
|
67
|
+
| `author` | ✓ | Your GitHub username |
|
|
68
|
+
| `verified` | | `true` once a second native speaker has checked it |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohammed Hossain and bangla-ai-eval contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: bangla-ai-eval
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Open benchmark for how well AI models handle Bangla and everyday Bangladeshi tasks.
|
|
5
|
+
Project-URL: Homepage, https://github.com/hossainbuilds/bangla-ai-eval
|
|
6
|
+
Project-URL: Issues, https://github.com/hossainbuilds/bangla-ai-eval/issues
|
|
7
|
+
Project-URL: Contributing, https://github.com/hossainbuilds/bangla-ai-eval/blob/main/CONTRIBUTING.md
|
|
8
|
+
Author: Mohammed Hossain
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: bangla,bangladesh,benchmark,bengali,evaluation,llm,nlp
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Natural Language :: Bengali
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: pyyaml>=6.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# bangla-ai-eval
|
|
26
|
+
|
|
27
|
+
**How well do AI models actually handle Bangla?** An open benchmark of everyday Bangla and Bangladeshi tasks. Every test case is written or checked by a native speaker.
|
|
28
|
+
|
|
29
|
+
> বাংলায় AI কতটা ভালো, সেটা মাপার একটা খোলা পরীক্ষা। প্রতিটা প্রশ্ন একজন বাংলাভাষী লিখেছেন বা যাচাই করেছেন। **কোড না জানলেও অবদান রাখতে পারবেন:** নিচে দেখুন।
|
|
30
|
+
|
|
31
|
+
[](https://github.com/hossainbuilds/bangla-ai-eval/actions/workflows/ci.yml)
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
## Why
|
|
35
|
+
|
|
36
|
+
Over 270 million people speak Bangla. AI models often look fluent in it, but trip over things any Bangladeshi gets right without thinking:
|
|
37
|
+
|
|
38
|
+
- **Irregular number words.** ৫৩ is *তিপ্পান্ন*, not "পঞ্চাশ তিন".
|
|
39
|
+
- **Lakh/crore commas.** Money is written ১২,৩৪,৫৬৭, not 1,234,567.
|
|
40
|
+
- **Banglish.** People type `order ta kobe pabo?`, and a model should read it back as *অর্ডারটা কবে পাবো?*
|
|
41
|
+
- **The Bangla calendar** as used in Bangladesh, where Pohela Boishakh is 14 April.
|
|
42
|
+
|
|
43
|
+
These mistakes matter when businesses here use AI for invoices, customer chat and content. This benchmark measures them so anyone can see how each model does.
|
|
44
|
+
|
|
45
|
+
## What's inside (v0.1)
|
|
46
|
+
|
|
47
|
+
**Everyday Bangla**
|
|
48
|
+
|
|
49
|
+
| Category | What it tests | Cases | |
|
|
50
|
+
|---|---|---|---|
|
|
51
|
+
| `digits` | Bangla ↔ English digits | 12 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/digits.yaml) |
|
|
52
|
+
| `taka-format` | Lakh/crore comma grouping | 10 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/taka-format.yaml) |
|
|
53
|
+
| `number-words` | Numbers written as Bangla words | 24 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/number-words.yaml) |
|
|
54
|
+
| `banglish` | Banglish → Bangla script | 8 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/banglish.yaml) |
|
|
55
|
+
| `bd-facts` | National symbols, dates, places, food (no politics) | 20 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/bd-facts.yaml) |
|
|
56
|
+
| `bangla-calendar` | Months, seasons, Bangladesh's revised calendar | 15 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/bangla-calendar.yaml) |
|
|
57
|
+
|
|
58
|
+
**🏆 AI কে হারাও: the hard part**
|
|
59
|
+
|
|
60
|
+
| Category | What it tests | Cases | |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| `dialect` | Chittagonian, Sylheti, Noakhali words → standard Bangla | 7 | [➕ তোমার এলাকার শব্দ দাও](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/dialect.yaml) |
|
|
63
|
+
| `proverbs` | Complete a প্রবাদ | 10 | [➕ প্রবাদ যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/proverbs.yaml) |
|
|
64
|
+
| `riddles` | Classic ধাঁধা | 3 | [➕ ধাঁধা যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/riddles.yaml) |
|
|
65
|
+
| `grammar` | Opposite words, সন্ধি বিচ্ছেদ | 10 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/grammar.yaml) |
|
|
66
|
+
|
|
67
|
+
Clicking ➕ opens the file in GitHub's editor. GitHub makes your own copy (fork) automatically, so you just add your question at the bottom and press **Propose changes**. Have an idea for a whole new category? [Create a new file](https://github.com/hossainbuilds/bangla-ai-eval/new/main/cases).
|
|
68
|
+
|
|
69
|
+
Run `python -m bangla_eval stats` for live counts. Every v0.1 case has been reviewed by a native speaker (`verified: true`). New contributions start as `verified: false` until a reviewer checks them. Use `--only-verified` to score only reviewed cases.
|
|
70
|
+
|
|
71
|
+
## Run it
|
|
72
|
+
|
|
73
|
+
Python 3.10+, one dependency. The cases ship inside the package.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install bangla-ai-eval
|
|
77
|
+
bangla-eval validate # check all cases
|
|
78
|
+
bangla-eval run --provider mock # dry run, no API key, no cost
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Against a real model (API keys come from environment variables only):
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Anthropic
|
|
85
|
+
export ANTHROPIC_API_KEY=...
|
|
86
|
+
bangla-eval run --provider anthropic --model <model-id>
|
|
87
|
+
|
|
88
|
+
# Anything OpenAI-compatible: OpenAI, Gemini, OpenRouter, Ollama, LM Studio
|
|
89
|
+
export OPENAI_API_KEY=...
|
|
90
|
+
bangla-eval run --provider openai --model <model-id> --base-url <endpoint>
|
|
91
|
+
|
|
92
|
+
bangla-eval report # markdown table of all runs
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Working from a clone of this repo (to add cases), use `pip install PyYAML` and `python -m bangla_eval ...` instead.
|
|
96
|
+
|
|
97
|
+
Each run is saved to `results/` with every prompt, response and score, so any number can be checked by hand.
|
|
98
|
+
|
|
99
|
+
## Results
|
|
100
|
+
|
|
101
|
+
*Coming soon: the first model runs.* Scores are published together with every raw response, so anyone can check them.
|
|
102
|
+
|
|
103
|
+
### 🏆 Hall of Fame: questions AI got wrong
|
|
104
|
+
|
|
105
|
+
When a question stumps a major model, it goes here, with the model's actual wrong answer and the contributor's name. Generated by `python -m bangla_eval hardest`.
|
|
106
|
+
|
|
107
|
+
*Fills up with the first results.* Think you can stump an AI? [Open a "Stump the AI" issue](https://github.com/hossainbuilds/bangla-ai-eval/issues/new?template=stump-the-ai.yml) or add the question yourself.
|
|
108
|
+
|
|
109
|
+
## Contribute: no code needed
|
|
110
|
+
|
|
111
|
+
The most valuable contribution is **a good question**: one that any Bangladeshi gets right, and that a model might not.
|
|
112
|
+
|
|
113
|
+
1. Open a file in [`cases/`](cases), or start a new category
|
|
114
|
+
2. Add your case at the end (copy the shape of the one above it)
|
|
115
|
+
3. Open a pull request. CI checks the format automatically.
|
|
116
|
+
|
|
117
|
+
Full guide in Bangla and English: [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
118
|
+
|
|
119
|
+
## How scoring works
|
|
120
|
+
|
|
121
|
+
- Answers are compared after Unicode normalization (NFC, invisible joiners removed, surrounding punctuation stripped). Invisible differences never fail a model, but real spelling differences do.
|
|
122
|
+
- Bangla often has more than one accepted spelling (*ষোলো / ষোল*). Each case lists every accepted form under `accept`.
|
|
123
|
+
- Models are asked to answer with only the final answer, at temperature 0.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT, covering both code and test cases. Built by [Mohammed Hossain](https://github.com/hossainbuilds) and contributors.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# bangla-ai-eval
|
|
2
|
+
|
|
3
|
+
**How well do AI models actually handle Bangla?** An open benchmark of everyday Bangla and Bangladeshi tasks. Every test case is written or checked by a native speaker.
|
|
4
|
+
|
|
5
|
+
> বাংলায় AI কতটা ভালো, সেটা মাপার একটা খোলা পরীক্ষা। প্রতিটা প্রশ্ন একজন বাংলাভাষী লিখেছেন বা যাচাই করেছেন। **কোড না জানলেও অবদান রাখতে পারবেন:** নিচে দেখুন।
|
|
6
|
+
|
|
7
|
+
[](https://github.com/hossainbuilds/bangla-ai-eval/actions/workflows/ci.yml)
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## Why
|
|
11
|
+
|
|
12
|
+
Over 270 million people speak Bangla. AI models often look fluent in it, but trip over things any Bangladeshi gets right without thinking:
|
|
13
|
+
|
|
14
|
+
- **Irregular number words.** ৫৩ is *তিপ্পান্ন*, not "পঞ্চাশ তিন".
|
|
15
|
+
- **Lakh/crore commas.** Money is written ১২,৩৪,৫৬৭, not 1,234,567.
|
|
16
|
+
- **Banglish.** People type `order ta kobe pabo?`, and a model should read it back as *অর্ডারটা কবে পাবো?*
|
|
17
|
+
- **The Bangla calendar** as used in Bangladesh, where Pohela Boishakh is 14 April.
|
|
18
|
+
|
|
19
|
+
These mistakes matter when businesses here use AI for invoices, customer chat and content. This benchmark measures them so anyone can see how each model does.
|
|
20
|
+
|
|
21
|
+
## What's inside (v0.1)
|
|
22
|
+
|
|
23
|
+
**Everyday Bangla**
|
|
24
|
+
|
|
25
|
+
| Category | What it tests | Cases | |
|
|
26
|
+
|---|---|---|---|
|
|
27
|
+
| `digits` | Bangla ↔ English digits | 12 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/digits.yaml) |
|
|
28
|
+
| `taka-format` | Lakh/crore comma grouping | 10 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/taka-format.yaml) |
|
|
29
|
+
| `number-words` | Numbers written as Bangla words | 24 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/number-words.yaml) |
|
|
30
|
+
| `banglish` | Banglish → Bangla script | 8 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/banglish.yaml) |
|
|
31
|
+
| `bd-facts` | National symbols, dates, places, food (no politics) | 20 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/bd-facts.yaml) |
|
|
32
|
+
| `bangla-calendar` | Months, seasons, Bangladesh's revised calendar | 15 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/bangla-calendar.yaml) |
|
|
33
|
+
|
|
34
|
+
**🏆 AI কে হারাও: the hard part**
|
|
35
|
+
|
|
36
|
+
| Category | What it tests | Cases | |
|
|
37
|
+
|---|---|---|---|
|
|
38
|
+
| `dialect` | Chittagonian, Sylheti, Noakhali words → standard Bangla | 7 | [➕ তোমার এলাকার শব্দ দাও](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/dialect.yaml) |
|
|
39
|
+
| `proverbs` | Complete a প্রবাদ | 10 | [➕ প্রবাদ যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/proverbs.yaml) |
|
|
40
|
+
| `riddles` | Classic ধাঁধা | 3 | [➕ ধাঁধা যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/riddles.yaml) |
|
|
41
|
+
| `grammar` | Opposite words, সন্ধি বিচ্ছেদ | 10 | [➕ প্রশ্ন যোগ করো](https://github.com/hossainbuilds/bangla-ai-eval/edit/main/cases/grammar.yaml) |
|
|
42
|
+
|
|
43
|
+
Clicking ➕ opens the file in GitHub's editor. GitHub makes your own copy (fork) automatically, so you just add your question at the bottom and press **Propose changes**. Have an idea for a whole new category? [Create a new file](https://github.com/hossainbuilds/bangla-ai-eval/new/main/cases).
|
|
44
|
+
|
|
45
|
+
Run `python -m bangla_eval stats` for live counts. Every v0.1 case has been reviewed by a native speaker (`verified: true`). New contributions start as `verified: false` until a reviewer checks them. Use `--only-verified` to score only reviewed cases.
|
|
46
|
+
|
|
47
|
+
## Run it
|
|
48
|
+
|
|
49
|
+
Python 3.10+, one dependency. The cases ship inside the package.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install bangla-ai-eval
|
|
53
|
+
bangla-eval validate # check all cases
|
|
54
|
+
bangla-eval run --provider mock # dry run, no API key, no cost
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Against a real model (API keys come from environment variables only):
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Anthropic
|
|
61
|
+
export ANTHROPIC_API_KEY=...
|
|
62
|
+
bangla-eval run --provider anthropic --model <model-id>
|
|
63
|
+
|
|
64
|
+
# Anything OpenAI-compatible: OpenAI, Gemini, OpenRouter, Ollama, LM Studio
|
|
65
|
+
export OPENAI_API_KEY=...
|
|
66
|
+
bangla-eval run --provider openai --model <model-id> --base-url <endpoint>
|
|
67
|
+
|
|
68
|
+
bangla-eval report # markdown table of all runs
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Working from a clone of this repo (to add cases), use `pip install PyYAML` and `python -m bangla_eval ...` instead.
|
|
72
|
+
|
|
73
|
+
Each run is saved to `results/` with every prompt, response and score, so any number can be checked by hand.
|
|
74
|
+
|
|
75
|
+
## Results
|
|
76
|
+
|
|
77
|
+
*Coming soon: the first model runs.* Scores are published together with every raw response, so anyone can check them.
|
|
78
|
+
|
|
79
|
+
### 🏆 Hall of Fame: questions AI got wrong
|
|
80
|
+
|
|
81
|
+
When a question stumps a major model, it goes here, with the model's actual wrong answer and the contributor's name. Generated by `python -m bangla_eval hardest`.
|
|
82
|
+
|
|
83
|
+
*Fills up with the first results.* Think you can stump an AI? [Open a "Stump the AI" issue](https://github.com/hossainbuilds/bangla-ai-eval/issues/new?template=stump-the-ai.yml) or add the question yourself.
|
|
84
|
+
|
|
85
|
+
## Contribute: no code needed
|
|
86
|
+
|
|
87
|
+
The most valuable contribution is **a good question**: one that any Bangladeshi gets right, and that a model might not.
|
|
88
|
+
|
|
89
|
+
1. Open a file in [`cases/`](cases), or start a new category
|
|
90
|
+
2. Add your case at the end (copy the shape of the one above it)
|
|
91
|
+
3. Open a pull request. CI checks the format automatically.
|
|
92
|
+
|
|
93
|
+
Full guide in Bangla and English: [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
94
|
+
|
|
95
|
+
## How scoring works
|
|
96
|
+
|
|
97
|
+
- Answers are compared after Unicode normalization (NFC, invisible joiners removed, surrounding punctuation stripped). Invisible differences never fail a model, but real spelling differences do.
|
|
98
|
+
- Bangla often has more than one accepted spelling (*ষোলো / ষোল*). Each case lists every accepted form under `accept`.
|
|
99
|
+
- Models are asked to answer with only the final answer, at temperature 0.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT, covering both code and test cases. Built by [Mohammed Hossain](https://github.com/hossainbuilds) and contributors.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"""Command line: python -m bangla_eval <validate|stats|run|report>"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from .cases import CASES_DIR, RESULTS_DIR, load_all, validate
|
|
11
|
+
from .providers import Anthropic, Mock, OpenAICompatible
|
|
12
|
+
from .run import hall_of_fame_markdown, hardest, markdown_table, run, save, summarize
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _utf8_stdout() -> None:
|
|
16
|
+
# Windows consoles default to a legacy code page and crash on Bangla text.
|
|
17
|
+
for stream in (sys.stdout, sys.stderr):
|
|
18
|
+
if hasattr(stream, "reconfigure"):
|
|
19
|
+
stream.reconfigure(encoding="utf-8")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def cmd_validate(args) -> int:
|
|
23
|
+
files = load_all(Path(args.cases))
|
|
24
|
+
errors = validate(files)
|
|
25
|
+
n = sum(len(f.cases) for f in files)
|
|
26
|
+
if errors:
|
|
27
|
+
print(f"✗ {len(errors)} problem(s) in {n} cases:")
|
|
28
|
+
for e in errors:
|
|
29
|
+
print(" -", e)
|
|
30
|
+
return 1
|
|
31
|
+
print(f"✓ {n} cases in {len(files)} files are valid")
|
|
32
|
+
return 0
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def cmd_stats(args) -> int:
|
|
36
|
+
files = load_all(Path(args.cases))
|
|
37
|
+
total = verified = 0
|
|
38
|
+
print(f"{'category':<20} {'cases':>6} {'verified':>9}")
|
|
39
|
+
for f in files:
|
|
40
|
+
v = sum(1 for c in f.cases if c.get("verified"))
|
|
41
|
+
total += len(f.cases)
|
|
42
|
+
verified += v
|
|
43
|
+
print(f"{f.category:<20} {len(f.cases):>6} {v:>9}")
|
|
44
|
+
authors = sorted({c.get("author") for f in files for c in f.cases if c.get("author")})
|
|
45
|
+
print(f"{'TOTAL':<20} {total:>6} {verified:>9}")
|
|
46
|
+
print(f"authors: {len(authors)} ({', '.join(authors)})")
|
|
47
|
+
return 0
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _provider(args):
|
|
51
|
+
if args.provider == "openai":
|
|
52
|
+
return OpenAICompatible(args.model, base_url=args.base_url, api_key_env=args.api_key_env or "OPENAI_API_KEY")
|
|
53
|
+
if args.provider == "anthropic":
|
|
54
|
+
return Anthropic(args.model, api_key_env=args.api_key_env or "ANTHROPIC_API_KEY")
|
|
55
|
+
files = load_all(Path(args.cases))
|
|
56
|
+
return Mock({c["prompt"]: str(c.get("answer", "")) for f in files for c in f.cases})
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def cmd_run(args) -> int:
|
|
60
|
+
files = load_all(Path(args.cases))
|
|
61
|
+
errors = validate(files)
|
|
62
|
+
if errors:
|
|
63
|
+
print("Fix the case files first (python -m bangla_eval validate).")
|
|
64
|
+
return 1
|
|
65
|
+
provider = _provider(args)
|
|
66
|
+
|
|
67
|
+
def progress(cid, ok, err):
|
|
68
|
+
mark = "!" if err else ("✓" if ok else "✗")
|
|
69
|
+
print(f" {mark} {cid}" + (f" ({err[:80]})" if err else ""))
|
|
70
|
+
|
|
71
|
+
data = run(provider, files, only_verified=args.only_verified, limit=args.limit,
|
|
72
|
+
progress=None if args.quiet else progress)
|
|
73
|
+
path = save(data, Path(args.out))
|
|
74
|
+
s = summarize(data)
|
|
75
|
+
c, t = s["overall"]
|
|
76
|
+
print(f"\n{s['model']}: {c}/{t} correct ({100 * c / max(t, 1):.1f}%), {s['errors']} errors → {path}")
|
|
77
|
+
return 0
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def cmd_report(args) -> int:
|
|
81
|
+
paths = [Path(p) for p in args.files] or sorted(Path(args.out).glob("*.json"))
|
|
82
|
+
if not paths:
|
|
83
|
+
print("No result files found.")
|
|
84
|
+
return 1
|
|
85
|
+
summaries = [summarize(json.loads(p.read_text(encoding="utf-8"))) for p in paths]
|
|
86
|
+
print(markdown_table(summaries))
|
|
87
|
+
return 0
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def cmd_hardest(args) -> int:
|
|
91
|
+
paths = [Path(p) for p in args.files] or sorted(Path(args.out).glob("*.json"))
|
|
92
|
+
if not paths:
|
|
93
|
+
print("No result files found.")
|
|
94
|
+
return 1
|
|
95
|
+
runs = [json.loads(p.read_text(encoding="utf-8")) for p in paths]
|
|
96
|
+
print(hall_of_fame_markdown(hardest(runs, min_failed=args.min_failed), top=args.top))
|
|
97
|
+
return 0
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def cmd_export(args) -> int:
|
|
101
|
+
from .export import write_jsonl
|
|
102
|
+
files = load_all(Path(args.cases))
|
|
103
|
+
problems = validate(files)
|
|
104
|
+
if problems:
|
|
105
|
+
print(f"✗ {len(problems)} problem(s); run `validate` and fix them before exporting")
|
|
106
|
+
return 1
|
|
107
|
+
out = Path(args.out)
|
|
108
|
+
n = write_jsonl(files, out)
|
|
109
|
+
print(f"wrote {n} cases → {out}")
|
|
110
|
+
return 0
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def main(argv=None) -> int:
|
|
114
|
+
_utf8_stdout()
|
|
115
|
+
p = argparse.ArgumentParser(prog="bangla_eval", description="Open benchmark for AI models on Bangla.")
|
|
116
|
+
p.add_argument("--cases", default=str(CASES_DIR), help="folder with case YAML files")
|
|
117
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
118
|
+
|
|
119
|
+
sub.add_parser("validate", help="check every case file")
|
|
120
|
+
sub.add_parser("stats", help="count cases per category")
|
|
121
|
+
|
|
122
|
+
r = sub.add_parser("run", help="run a model over the cases")
|
|
123
|
+
r.add_argument("--provider", choices=["openai", "anthropic", "mock"], required=True)
|
|
124
|
+
r.add_argument("--model", default="mock")
|
|
125
|
+
r.add_argument("--base-url", default="https://api.openai.com/v1",
|
|
126
|
+
help="OpenAI-compatible endpoint (Gemini, OpenRouter, Ollama...)")
|
|
127
|
+
r.add_argument("--api-key-env", help="name of the env var holding the API key")
|
|
128
|
+
r.add_argument("--only-verified", action="store_true", help="skip cases not yet checked by a reviewer")
|
|
129
|
+
r.add_argument("--limit", type=int, help="run only the first N cases")
|
|
130
|
+
r.add_argument("--out", default=str(RESULTS_DIR))
|
|
131
|
+
r.add_argument("--quiet", action="store_true")
|
|
132
|
+
|
|
133
|
+
rep = sub.add_parser("report", help="markdown table from result files")
|
|
134
|
+
rep.add_argument("files", nargs="*")
|
|
135
|
+
rep.add_argument("--out", default=str(RESULTS_DIR))
|
|
136
|
+
|
|
137
|
+
h = sub.add_parser("hardest", help="Hall of Fame: questions that models got wrong")
|
|
138
|
+
h.add_argument("files", nargs="*")
|
|
139
|
+
h.add_argument("--out", default=str(RESULTS_DIR))
|
|
140
|
+
h.add_argument("--min-failed", type=int, default=1)
|
|
141
|
+
h.add_argument("--top", type=int, default=20)
|
|
142
|
+
|
|
143
|
+
e = sub.add_parser("export", help="write all cases as one JSONL file (Hugging Face / lm-eval)")
|
|
144
|
+
e.add_argument("--out", default="test.jsonl")
|
|
145
|
+
|
|
146
|
+
args = p.parse_args(argv)
|
|
147
|
+
return {"validate": cmd_validate, "stats": cmd_stats, "run": cmd_run, "report": cmd_report,
|
|
148
|
+
"hardest": cmd_hardest, "export": cmd_export}[args.cmd](args)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if __name__ == "__main__":
|
|
152
|
+
sys.exit(main())
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Load and validate the test-case YAML files in cases/."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import yaml
|
|
10
|
+
|
|
11
|
+
PKG_DIR = Path(__file__).resolve().parent
|
|
12
|
+
ROOT = PKG_DIR.parent
|
|
13
|
+
# In a git checkout the cases live at the repo root; in an installed wheel
|
|
14
|
+
# they are bundled inside the package (see pyproject.toml force-include).
|
|
15
|
+
IN_REPO = (ROOT / "pyproject.toml").is_file() and (ROOT / "cases").is_dir()
|
|
16
|
+
CASES_DIR = ROOT / "cases" if IN_REPO else PKG_DIR / "cases"
|
|
17
|
+
RESULTS_DIR = ROOT / "results" if IN_REPO else Path.cwd() / "results"
|
|
18
|
+
|
|
19
|
+
MATCH_MODES = {"exact", "contains", "regex"}
|
|
20
|
+
CASE_KEYS = {"id", "prompt", "answer", "accept", "match", "pattern", "fold_digits", "note", "author", "verified"}
|
|
21
|
+
FILE_KEYS = {"category", "title", "description", "cases"}
|
|
22
|
+
ID_RE = re.compile(r"^[a-z0-9]+(-[a-z0-9]+)*-\d{3}$")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class CaseFile:
|
|
27
|
+
path: Path
|
|
28
|
+
category: str
|
|
29
|
+
title: str
|
|
30
|
+
description: str
|
|
31
|
+
cases: list[dict] = field(default_factory=list)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def load_file(path: Path) -> CaseFile:
|
|
35
|
+
with open(path, encoding="utf-8") as fh:
|
|
36
|
+
data = yaml.safe_load(fh) or {}
|
|
37
|
+
return CaseFile(
|
|
38
|
+
path=path,
|
|
39
|
+
category=data.get("category", ""),
|
|
40
|
+
title=data.get("title", ""),
|
|
41
|
+
description=data.get("description", ""),
|
|
42
|
+
cases=list(data.get("cases") or []),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def load_all(cases_dir: Path = CASES_DIR) -> list[CaseFile]:
|
|
47
|
+
return [load_file(p) for p in sorted(cases_dir.glob("*.yaml"))]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def validate(files: list[CaseFile]) -> list[str]:
|
|
51
|
+
"""Return a list of human-readable problems. Empty list = all good."""
|
|
52
|
+
errors: list[str] = []
|
|
53
|
+
seen_ids: dict[str, str] = {}
|
|
54
|
+
seen_prompts: dict[str, str] = {}
|
|
55
|
+
|
|
56
|
+
for f in files:
|
|
57
|
+
where = f.path.name
|
|
58
|
+
with open(f.path, encoding="utf-8") as fh:
|
|
59
|
+
raw = yaml.safe_load(fh) or {}
|
|
60
|
+
for key in set(raw) - FILE_KEYS:
|
|
61
|
+
errors.append(f"{where}: unknown top-level key '{key}'")
|
|
62
|
+
if not f.category:
|
|
63
|
+
errors.append(f"{where}: missing 'category'")
|
|
64
|
+
elif f.path.stem != f.category:
|
|
65
|
+
errors.append(f"{where}: file name must match category '{f.category}'")
|
|
66
|
+
if not f.title:
|
|
67
|
+
errors.append(f"{where}: missing 'title'")
|
|
68
|
+
if not f.cases:
|
|
69
|
+
errors.append(f"{where}: no cases")
|
|
70
|
+
|
|
71
|
+
for i, c in enumerate(f.cases):
|
|
72
|
+
label = f"{where} case #{i + 1}"
|
|
73
|
+
if not isinstance(c, dict):
|
|
74
|
+
errors.append(f"{label}: must be a mapping")
|
|
75
|
+
continue
|
|
76
|
+
cid = c.get("id")
|
|
77
|
+
if cid:
|
|
78
|
+
label = f"{where} [{cid}]"
|
|
79
|
+
for key in set(c) - CASE_KEYS:
|
|
80
|
+
errors.append(f"{label}: unknown key '{key}'")
|
|
81
|
+
if not cid:
|
|
82
|
+
errors.append(f"{label}: missing 'id'")
|
|
83
|
+
else:
|
|
84
|
+
if not ID_RE.match(str(cid)):
|
|
85
|
+
errors.append(f"{label}: id must look like '<category>-001'")
|
|
86
|
+
elif f.category and not str(cid).startswith(f.category + "-"):
|
|
87
|
+
errors.append(f"{label}: id must start with '{f.category}-'")
|
|
88
|
+
if cid in seen_ids:
|
|
89
|
+
errors.append(f"{label}: duplicate id (also in {seen_ids[cid]})")
|
|
90
|
+
seen_ids[cid] = where
|
|
91
|
+
prompt = str(c.get("prompt") or "").strip()
|
|
92
|
+
if not prompt:
|
|
93
|
+
errors.append(f"{label}: missing 'prompt'")
|
|
94
|
+
elif prompt in seen_prompts:
|
|
95
|
+
errors.append(f"{label}: duplicate prompt (also {seen_prompts[prompt]})")
|
|
96
|
+
else:
|
|
97
|
+
seen_prompts[prompt] = str(cid)
|
|
98
|
+
mode = c.get("match", "exact")
|
|
99
|
+
if mode not in MATCH_MODES:
|
|
100
|
+
errors.append(f"{label}: match must be one of {sorted(MATCH_MODES)}")
|
|
101
|
+
if mode == "regex":
|
|
102
|
+
if not c.get("pattern"):
|
|
103
|
+
errors.append(f"{label}: regex match needs 'pattern'")
|
|
104
|
+
else:
|
|
105
|
+
try:
|
|
106
|
+
re.compile(c["pattern"])
|
|
107
|
+
except re.error as exc:
|
|
108
|
+
errors.append(f"{label}: bad regex: {exc}")
|
|
109
|
+
elif c.get("answer") in (None, ""):
|
|
110
|
+
errors.append(f"{label}: missing 'answer'")
|
|
111
|
+
if "accept" in c and not isinstance(c["accept"], list):
|
|
112
|
+
errors.append(f"{label}: 'accept' must be a list")
|
|
113
|
+
if "verified" in c and not isinstance(c["verified"], bool):
|
|
114
|
+
errors.append(f"{label}: 'verified' must be true or false")
|
|
115
|
+
if not c.get("author"):
|
|
116
|
+
errors.append(f"{label}: missing 'author' (your GitHub username)")
|
|
117
|
+
return errors
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Export the cases as flat JSONL, e.g. for a Hugging Face dataset or lm-evaluation-harness.
|
|
2
|
+
|
|
3
|
+
Every record has the same keys and types (no nulls), so dataset loaders infer
|
|
4
|
+
one stable schema.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from .cases import CaseFile
|
|
13
|
+
from .scoring import accepted_answers
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def to_records(files: list[CaseFile]) -> list[dict]:
|
|
17
|
+
records = []
|
|
18
|
+
for f in files:
|
|
19
|
+
for c in f.cases:
|
|
20
|
+
records.append({
|
|
21
|
+
"id": c["id"],
|
|
22
|
+
"category": f.category,
|
|
23
|
+
"prompt": c["prompt"],
|
|
24
|
+
"answer": "" if c.get("answer") is None else str(c["answer"]),
|
|
25
|
+
"accept": accepted_answers(c),
|
|
26
|
+
"match": c.get("match", "exact"),
|
|
27
|
+
"pattern": c.get("pattern") or "",
|
|
28
|
+
"fold_digits": bool(c.get("fold_digits", False)),
|
|
29
|
+
"author": c.get("author", ""),
|
|
30
|
+
"verified": bool(c.get("verified", False)),
|
|
31
|
+
})
|
|
32
|
+
return records
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def write_jsonl(files: list[CaseFile], path: Path) -> int:
|
|
36
|
+
records = to_records(files)
|
|
37
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
38
|
+
with open(path, "w", encoding="utf-8", newline="\n") as fh:
|
|
39
|
+
for r in records:
|
|
40
|
+
fh.write(json.dumps(r, ensure_ascii=False) + "\n")
|
|
41
|
+
return len(records)
|