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

To install the project and dependencies you can use pip.

pip install qstn

Or 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


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.1.5.1.tar.gz (179.1 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.1.5.1-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qstn-0.1.5.1.tar.gz
Algorithm Hash digest
SHA256 56dc6116eed26f5339c10adb041960c1c209cbb0b2dfdcb3cdd8af3e757d5a32
MD5 948117c7fa3e9d1bcb524846c2fc6840
BLAKE2b-256 eab9faec420b7931d048572980c3c2abc577c4e587746a561512a56ac1760ae1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qstn-0.1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 43.4 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.1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e5e8f894d29f73c71d501d918c3d088839378dc1755f57d01d9d1468def0d80
MD5 89466894bd24ff37b5eb2d6a1e82e6d2
BLAKE2b-256 3c4c0df91ef36a1941a7b00b9d9a10c456afcc015eca4db8b898aa23978a3bb8

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