Software
stance-llm
: A Python package to classify stances of entities in text, using large language models
In the sustainability.discourses Project, we developed stance-llm, a Python package to leverage large language models to classify stances of entities in German text. A preprint with evaluations of the method can be found at https://doi.org/10.31235/osf.io/5a3k8_v1.
Check it out on https://github.com/urban-sustainability-lab-zurich/stance-llm, it’s also on PyPi.
Here’s a quick sample:
-llm
pip install stance pip install guidance
1from guidance import models
from stance_llm.process import detect_stance
2= models.Transformers("DiscoResearch/DiscoLM_German_7b_v1")
disco7b
= [
my_eg "text":"Emily will LLMs in den Papageienzoo sperren und streng beaufsichtigen.",
{"ent_text": "Emily",
3"statement": "LLMs sollten in den Papageienzoo gesperrt werden."}]
= detect_stance(
classification = my_eg,
eg = disco7b,
llm 4= "is"
chain_label
)
classification.stance
- 1
- stance-llm relies on guidance
- 2
- Choose an LLM accessible through guidance (Transformers, LlamaCpp, OpenAI)
- 3
- The task format
- 4
- This is where you can choose a prompt chain
motifr
: An R package to study multi-level network motifs
Together with the phenomenal Tim Seppelt, I implemented motifr, an R package to analyse multi-level networks in terms of motifs.
All up to data information on the package can be found on the package homepage: https://marioangst.github.io/motifr/
Multi-level networks combine multiple networks in one representation, e.g. social-ecological networks, which connect a social network (e.g. interactions among fishermen) with an ecological network (e.g. interactions between fish species) and the ties in between (e.g. fishers who fish specific species).
Motifs are small configurations of nodes and edges (subgraphs) within an overall network.
Package features include:
- Visualization: The package provides functions to visualize multi-level networks, based on ggraph.
- Motif counts: The package is in many parts a R wrapper for the excellent SESMotifAnalyser Python framework written by Tim Seppelt to count multi-level network motifs, compare them to a baseline and much more.
- Contributions of edges to motifs: motifr further identifies and visualizes functional gaps and critical edges in multi-level networks based on contributions of existing or potential edges to given motifs (this is theoretically motivated by network theories of functional fit and misfit).
🧶 🤖 rayab
🤖 🧶: An R package for knitting data on hacked 70s knitting machines
A web application interface to use rayab is live at https://ayab.discourses.ch. Code for the application is available at https://github.com/marioangst/rayab-web
rayab is an R package, which provides functionality to create images suitable for two-color knitting via the AYAB (all yarns are beautiful) open source software/ hardware project. Briefly, the goal of the AYAB project is “to provide an alternative way to control the famous Brother KH-9xx range of knitting machines using a computer” (https://www.ayab-knitting.com).
Because printing your data visualizations is so last century. In this century, we knit them using hacked 1970s knitting machines!
rayab includes functions to convert to images suitable for transfer to the AYAB software:
- ggplot plot objects
- text
- user-supplied images
rayab is developed at https://github.com/marioangst/rayab and available through https://marioangst.r-universe.dev/rayab.
eu-consultations
: A Python package for scraping textual data from EU public consultations
eu-consultations allows to scrape textual data from EU public consultation from https://ec.europa.eu/info/law/better-regulation. It’s aim is to facilitate academic analysis of how the public participates in EU public consultations. In EU public consultations, the broader public of the EU is asked to supply input to proposed regulations.
from eu_consultations.scrape import scrape
= scrape(
consultation_data 1=["DIGITAL"],
topic_list=<my-folder>,
output_folder2="<my-filename>.json") filename
- 1
- Scrape responses to all consultations on digital technology topics
- 2
- Store the responses as a .json file. Afterwards, the package lets you futher download and extract text from files people have uploaded as part of their responses.
eu-consultations is developed and a quickstart is given at https://github.com/marioangst/eu_consultations. It is available through PyPi https://pypi.org/project/eu-consultations/.
diskurs
: An R package to handle data on discourse networks
diskurs (German for discourse) is an R package to handle data on discourse networks in a very specific form. It is at an early stage of development at https://github.com/urban-sustainability-lab-zurich/diskurs and available through https://urban-sustainability-lab-zurich.r-universe.dev/diskurs.
The main goal of the package is to ensure validated data loading and basic transformations of discourse in graph structure as introduced in the sustainability.discourses project.
At the moment, it mainly exists to facilitate the reproduction of analyses conducted within the sustainability.discourses project. The eventual goal is to hopefully support anyone working with a similar data structure in the future.
1<- load_discourse_graph(edgelist = example_edgelist, nodelist = example_nodelist)
disc_g
disc_g#> ----------------------------------------
#> A discourse graph with 3 actors and 2
#> statements
#> ----------------------------------------
#> # A tbl_graph: 5 nodes and 7 edges
#> (output truncated...)
|>
disc_g aggregate_discourse_graph(keep_only_highest = TRUE) |>
2plot()
- 1
- Load discourse graph from specific edgelist and nodelist formats
- 2
- Aggregate graph and plot
MToolR
: An R package companion the mental model data gathering software M-Tool
MToolR is a companion package I have developed for the Mental Model Mapping Tool M-Tool (https://www.m-tool.org/) by Karlijn van den Broek. The package provides: a) functionality to load and process data generated by M-Tool b) procedures for common (basic) analytical tasks c) visualization functions.
Package homepage: https://marioangst.github.io/MToolR/
library(MToolR)
<-
mentalmodels ::mentalmodel_from_csv(
MToolR"data-raw/example_export.csv",
1exclude_nonresponse = TRUE)
plot(
mentalmodels, 2user = "ad84c4ed-b73e-4ba2-8e1f-edbe365bb225")
- 1
- Load data from a exported .csv file from M-Tool
- 2
- Plot the mental model of a single user