Skip to main content

itemwise

PyPI CI License: MIT Python 3.12+

LLM-based evaluation of multiple-choice items against the 43 item-writing rules from Haladyna & Downing (1989). Works with any OpenAI-compatible endpoint — hosted APIs (OpenAI, Azure, etc.) or a local server (vLLM, Ollama, LM Studio) for open-weight models.

Installation

pip install itemwise

Requires Python 3.12+.

Quick Start

from itemwise import evaluate

result = evaluate(
    item={
        "stem": "Which of the following is NOT a characteristic of mammals?",
        "options": [
            "They are warm-blooded",
            "They lay eggs",
            "They have hair or fur",
            "They produce milk",
        ],
        "correct": 1,
    },
    model="gpt-5.5",
    api_key="sk-...",  # or set OPENAI_API_KEY
)

print(result.score)            # fraction of rules passed
print(result.violations)       # list of failed RuleResult

Usage

from itemwise import evaluate, evaluate_batch, async_evaluate_batch

# Select specific rules
evaluate(item=item, model="gpt-5.5", rules=[22, 28, 37])

# Batch with progress bar (disable via progress=False)
evaluate_batch(items=items, model="gpt-5.5")

# Async / parallel
await async_evaluate_batch(items=items, model="gpt-5.5")

# Extra kwargs are forwarded to the OpenAI chat.completions API
evaluate(item=item, model="gpt-5.5", reasoning_effort="low")

CLI

itemwise evaluate questions.json --model gpt-5.5
itemwise evaluate questions.json --model gpt-5.5 --rules 22,28,37 --param reasoning_effort=low

Input JSON format:

[{"stem": "...", "options": ["A", "B", "C", "D"], "correct": 0}]

Endpoint Configuration

itemwise sends requests to any OpenAI-compatible endpoint. Point it at one with base_url / api_key (or the OPENAI_BASE_URL / OPENAI_API_KEY environment variables).

Hosted OpenAI (default endpoint):

export OPENAI_API_KEY=sk-...
itemwise evaluate questions.json --model gpt-5.5

Local open-weight model (GLM-5.2) via vLLM — start your own server, then point itemwise at it:

vllm serve zai-org/GLM-5.2  # exposes an OpenAI-compatible API at http://localhost:8000/v1
itemwise evaluate questions.json \
  --model zai-org/GLM-5.2 \
  --base-url http://localhost:8000/v1 \
  --api-key EMPTY
evaluate(
    item=item,
    model="zai-org/GLM-5.2",
    base_url="http://localhost:8000/v1",
    api_key="EMPTY",
)

Any other OpenAI-compatible server (Ollama, LM Studio, llama.cpp, etc.) works the same way — just set base_url to its address.

Item-Writing Rules

43 rules from Haladyna & Downing (1989) across 6 categories:

Category Rules Description
General (Procedural) 1-7 Format, grammar, readability
General (Content) 8-17 Objectives, vocabulary, higher-order thinking
Stem Construction 18-23 Clarity, positive wording
General Option 24-35 Count, order, homogeneity, length
Correct Option 36-37 Position distribution, uniqueness
Distractor 38-43 Plausibility, common errors

Rules 11 (item independence) and 36 (answer position distribution) require cross-item analysis and are excluded by default. Pass them explicitly via rules=[11, 36] to include them.

References

  • Haladyna, T. M., & Downing, S. M. (1989). A taxonomy of multiple-choice item-writing rules. Applied Measurement in Education, 2(1), 37-50.
  • Haladyna, T. M., Downing, S. M., & Rodriguez, M. C. (2002). A review of multiple-choice item-writing guidelines for classroom assessment. Applied Measurement in Education, 15(3), 309-333.

License

MIT

Download files

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

Source Distribution

itemwise-0.2.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

itemwise-0.2.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: itemwise-0.2.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for itemwise-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d498135bb953151d1d11c127a26ae44ff704568d82e47e046cf0a30e2dd073dc
MD5 b2f86f36143b073598d2b6775d409a1f
BLAKE2b-256 dcf29c462613c8d22caa341ffb8fcb3d45d9fa7902cc1130137439b553b2824b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: itemwise-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for itemwise-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5fdd2f168d739dc1b399eec353722d6cbbe9688c640e11ee48753606fdf5e854
MD5 7ab3645004f2e182bb99476b980481f6
BLAKE2b-256 25ea3664739b03352cbac6df0427f38e4c90b3ba04e6cc68b9d1b7e24e169fe8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page