Skip to main content

Archetypes!

This is a library developed to run what might be called a "souped-up dictionary method" for psychological text analysis. Or any kind of text analysis, really.

The core idea behind Archetypes is that you pre-define a set of prototypical sentences that reflect the construct that you are looking to measure in a body of text. Using modern contextual embeddings, then, this library will aggregate your prototypes into an archetypal representation of your construct. Then, you can quantify texts in your corpus for their semantic similarity to your construct(s) of interest.

Note: For the curious: no, this approach not inspired by anything Jungian in nature. In the past, I've said a few things about Jungian archetypes that have inspired scholars to write more than a few frustrated e-mails to me. Apologies to the Jungians.

Installation

This package is easily installable via pip via the following command:

pip install archetyper

Requirements

If you want to run the library without pip installing as shown above, you will need to first install the following packages:

  • numpy
  • tqdm
  • torch
  • sentence_transformers
  • nltk

You can try to install these all in one go by running the following command from your terminal/cmd:

pip install numpy tqdm torch sentence_transformers nltk

Examples

I have provided an example notebook in this repo that walks through the basic process of using this library, along with demonstrations of a few important "helper" functions to help you evaluate the statistical/psychometric qualities of your archetypes.

Citation

This method is originally described in this paper:

@inproceedings{varadarajan-etal-2024-archetypes,
    title = "Archetypes and Entropy: Theory-Driven Extraction of Evidence for Suicide Risk",
    author = "Varadarajan, Vasudha  and
      Lahnala, Allison  and
      Ganesan, Adithya V. and
      Dey, Gourab  and
      Mangalik, Siddharth  and
      Bucur, Ana-Maria  and
      Soni, Nikita  and
      Rao, Rajath  and
      Lanning, Kevin  and
      Vallejo, Isabella  and
      Flek, Lucie  and
      Schwartz, H. Andrew  and
      Welch, Charles  and
      Boyd, Ryan L.",
    editor = "Yates, Andrew  and
      Desmet, Bart  and
      Prud{'}hommeaux, Emily  and
      Zirikly, Ayah  and
      Bedrick, Steven  and
      MacAvaney, Sean  and
      Bar, Kfir  and
      Ireland, Molly  and
      Ophir, Yaakov",
    booktitle = "Proceedings of the 9th Workshop on Computational Linguistics and Clinical Psychology (CLPsych 2024)",
    month = mar,
    year = "2024",
    address = "St. Julians, Malta",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2024.clpsych-1.28",
    pages = "278--291",
    abstract = "Research on psychological risk factors for suicide has developed for decades. However, combining explainable theory with modern data-driven language model approaches is non-trivial. In this study, we propose and evaluate methods for identifying language patterns aligned with theories of suicide risk by combining theory-driven suicidal archetypes with language model-based and relative entropy-based approaches. Archetypes are based on prototypical statements that evince risk of suicidality while relative entropy considers the ratio of how unusual both a risk-familiar and unfamiliar model find the statements. While both approaches independently performed similarly, we find that combining the two significantly improved the performance in the shared task evaluations, yielding our combined system submission with a BERTScore Recall of 0.906. Consistent with the literature, we find that titles are highly informative as suicide risk evidence, despite the brevity. We conclude that a combination of theory- and data-driven methods are needed in the mental health space and can outperform more modern prompt-based methods.",
}

Metadata

Release files for archetyper 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for archetyper 1.2.3
File Size Uploaded Provenance Actions
archetyper-1.2.3.tar.gz 11.4 kB Without provenance Details for archetyper-1.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for archetyper 1.2.3
File Interpreter ABI Platform Actions
archetyper-1.2.3-py3-none-any.whl Python 3 none any Details for archetyper-1.2.3-py3-none-any.whl

Total release size: 23.0 kB

Release files / archetyper-1.2.3.tar.gz

Download URL archetyper-1.2.3.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c0bfd08842f4f8d9a4c248afb33179255a626483f8b803af3ea0041caa81f168
BLAKE2b-256 checksum
How to use checksums
27c64a82dbb284c1cc90c2cd2a8e5287fe22aea2df248ce299bc26f0fff44ede
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release files / archetyper-1.2.3-py3-none-any.whl

Download URL archetyper-1.2.3-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be04a8f685ad8e3f7741b37066cf1ed8cd49c6b6a5244be24fdcd8c1a5760481
BLAKE2b-256 checksum
How to use checksums
2de645dbfd7ad030a9b7353842c8bd320792f4b09b825aa067e49f3a37477fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Security for archetyper 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page