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
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
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:
@misc{kreutner2025qstnmodularframeworkrobust,
title={QSTN: A Modular Framework for Robust Questionnaire Inference with Large Language Models},
author={Maximilian Kreutner and Jens Rupprecht and Georg Ahnert and Ahmed Salem and Markus Strohmaier},
year={2025},
eprint={2512.08646},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2512.08646},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qstn-0.2.1.tar.gz.
File metadata
- Download URL: qstn-0.2.1.tar.gz
- Upload date:
- Size: 179.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
defa7ba16aa3dab283fdff0c0142234ede37d96ffc09d4a9c64c543b44c4dfd8
|
|
| MD5 |
58d5b55c4761197299c45afc135fb94b
|
|
| BLAKE2b-256 |
e1a0a78238c4229ac3195317c0245fabb63e6f8fb5e556a71d5c9609e71d0d32
|
File details
Details for the file qstn-0.2.1-py3-none-any.whl.
File metadata
- Download URL: qstn-0.2.1-py3-none-any.whl
- Upload date:
- Size: 45.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65ccaaf7b6217471785d3027291e9a9b3411eeab982075bcbc7415ae828d83ea
|
|
| MD5 |
6c76fc14c8e80347bb6c535411798509
|
|
| BLAKE2b-256 |
fbc9cbf2a069c0f9f0269f45e9e5a2c285877c6171bbfd9a2938c8866f2c6e02
|