Skip to main content

A Modular Framework for Robust Questionnaire Inference with Large Language Models

Project description

QSTN: A Modular Framework for Robust Questionnaire Inference with Large Language Models

Overview

QSTN is a Python framework designed to facilitate the creation of robust inference experiments with Large Language Models based around questionnaires. It provides a full pipeline from perturbation of prompts, to choosing Response Generation Methods, inferencing and finally parsing of the output. QSTN supports both local inference with vllm and remote inference via the OpenAI API.

Detailed information and guides are available in our documentation. Tutorial notebooks can also be found in this repository.

Installation

Make sure that the python version in your environment is at least 3.12

We support two type of installations:
1. The base version, which only installs the dependencies neccessary to use the OpenAI API.
2. The full version, which supports both API and local inference via vllm.

To install both of these version you can use pip or uv.

The base version can be installed with the following command:

pip install qstn

The full version can be installed with this command:

pip install qstn[vllm]

You can also install this package from source:

pip install git+https://github.com/dess-mannheim/QSTN.git

Getting Started

Below you can find a minimum working example of how to use QSTN. It can be easily integrated into existing projects, requiring just three function calls to operate. Users familiar with vllm or the OpenAI API can use the same Model/Client calls and arguments. In this example reasoning and the generated response are automatically parsed. For more elaborate examples, see the tutorial notebooks.

import qstn
import pandas as pd
from vllm import LLM

# 1. Prepare questionnaire and persona data
questionnaires = pd.read_csv("hf://datasets/qstn/ex/q.csv")
personas = pd.read_csv("hf://datasets/qstn/ex/p.csv")
prompt = (
    f"Please tell us how you feel about:\n"
    f"{qstn.utilities.placeholder.PROMPT_QUESTIONS}"
)
interviews = [
    qstn.prompt_builder.LLMPrompt(
        questionnaire_source=questionnaires,
        system_prompt=persona,
        prompt=prompt,
    ) for persona in personas.system_prompt]

# 2. Run Inference
model = LLM("Qwen/Qwen3-4B", max_model_len=5000)
results = qstn.survey_manager.conduct_survey_single_item(
    model, interviews, max_tokens=500
)

# 3. Parse Results
parsed_results = qstn.parser.raw_responses(results)

Citation

If you find QSTN useful in your work, please cite our paper:

@inproceedings{kreutner-etal-2026-qstn,
    title = "{QSTN}: A Modular Framework for Robust Questionnaire Inference with Large Language Models",
    author = "Kreutner, Maximilian  and
      Rupprecht, Jens  and
      Ahnert, Georg  and
      Salem, Ahmed  and
      Strohmaier, Markus",
    editor = "Croce, Danilo  and
      Leidner, Jochen  and
      Moosavi, Nafise Sadat",
    booktitle = "Proceedings of the 19th Conference of the {E}uropean Chapter of the {A}ssociation for {C}omputational {L}inguistics (Volume 3: System Demonstrations)",
    month = mar,
    year = "2026",
    address = "Rabat, Marocco",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2026.eacl-demo.37/",
    doi = "10.18653/v1/2026.eacl-demo.37",
    pages = "537--549",
    ISBN = "979-8-89176-382-1"
}

Project details


Download files

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

Source Distribution

qstn-0.3.3.tar.gz (246.4 kB view details)

Uploaded Source

Built Distribution

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

qstn-0.3.3-py3-none-any.whl (64.1 kB view details)

Uploaded Python 3

File details

Details for the file qstn-0.3.3.tar.gz.

File metadata

  • Download URL: qstn-0.3.3.tar.gz
  • Upload date:
  • Size: 246.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for qstn-0.3.3.tar.gz
Algorithm Hash digest
SHA256 cf48b383cc2b85a6f98bccd7ee722e84e7fa3be5a9cdec76f2fcb7ac89b17008
MD5 776adcb073e1c7c6b457f7b0a18ef858
BLAKE2b-256 0efc28d0bfd3a57f7fd8fb54d2ba6d5ccec7b6b49ce0e44b464d7648c466b469

See more details on using hashes here.

File details

Details for the file qstn-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: qstn-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 64.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for qstn-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 36b14e4e26c382f1d9d43425210a50ea437a3fbe2037518131f34f833f173a6c
MD5 5ec09f0be5de8038bf1da81d9d67d30b
BLAKE2b-256 7043a27dae35db1789fac8445db1a7d9ff8e1aea996e5f89f062ac2cba0be9e4

See more details on using hashes here.

Supported by

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