Propaganda technique detection pipeline using DSPy + OpenAI (23 techniques)
Project description
Propaganda Pipeline
Detects 23 propaganda and persuasion techniques in text using LLMs (DSPy + OpenAI).
Install the beta release
pip install git+https://github.com/marcelomendoza/propaganda-pipeline.git@v0.1.0-beta
Requirements
- Python ≥ 3.10
- OpenAI API key
Setup on a new machine
1. Clone the repo
git clone https://github.com/marcelomendoza/propaganda-pipeline.git
cd propaganda-pipeline
2. Install the package and its dependencies
pip install -e .
3. Set your OpenAI API key
export OPENAI_API_KEY="sk-..."
Add that line to your ~/.bashrc or ~/.zshrc to make it permanent.
4. Open the documentation
# Linux
xdg-open docs/index.html
# Mac
open docs/index.html
# Windows
Start-Process .\docs\index.html
The docs include the full API reference and a usage tutorial.
Quick start
import os
from propaganda_pipeline import Configuracion, Analisis, RunJuez, run_consistency
cfg = Configuracion(model_name="gpt-4o-2024-08-06", api_key=os.environ["OPENAI_API_KEY"])
cfg.setup()
text = "Either you support our policy completely or you want the country to fail."
analisis = Analisis()
candidates = run_consistency(analisis, text, trials=5, threshold=1.0)
result = RunJuez(text, candidates)
print(result["synthesis"]["final_answer"])
print(result["selected_models_posthoc"]["selected_models"])
See propaganda_pipeline_tutorial.ipynb or docs/tutorial.html for a full walkthrough.
Detected techniques (23)
| Technique | Description |
|---|---|
| REPETITION | Persuasion through repetition |
| EXAGERATION | Hyperbole or minimization |
| OBFUSCATION | Intentional vagueness |
| LOADED_LANGUAGE | Emotionally charged terms |
| WHATABOUTISM | Deflecting by pointing to others |
| KAIROS | Exploiting timing/urgency |
| KILLER | Conversation killers |
| SLIPPERY | Slippery slope fallacy |
| SLOGAN | Brief striking phrases as sole argument |
| VALUES | Appeal to abstract values |
| RED_HERRING | Introducing irrelevant information |
| STRAWMAN | Misrepresenting someone's position |
| FEAR | Appeal to fear or prejudice |
| AUTHORITY | Fallacious appeal to authority |
| BANDWAGON | Appeal to popularity |
| CASTING_DOUBT | Attacking credibility instead of argument |
| FLAG_WAVING | Appeal to group pride/identity |
| SMEAR_POISONING | Poisoning the well / reputation attacks |
| TU_QUOQUE | "You do it too" / appeal to hypocrisy |
| GUILT_BY_ASSOCIATION | Discrediting by association |
| NAME_CALLING | Derogatory labeling |
| CAUSAL_OVERSIMPLIFICATION | Attributing complex outcomes to a single cause |
| FALSE_DILEMMA | Presenting only two options when more exist |
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 propaganda_pipeline-1.0.0.tar.gz.
File metadata
- Download URL: propaganda_pipeline-1.0.0.tar.gz
- Upload date:
- Size: 69.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4072616909413074bcd50d99bb623a46c808a0eedafaab534035807c5b0f8862
|
|
| MD5 |
5e4bb3e9ef05b2b68164a5ccf2fa9a69
|
|
| BLAKE2b-256 |
b30014af87265cdc83c4b93294de946f3222a27afff9a3c558b7869fc77acafa
|
File details
Details for the file propaganda_pipeline-1.0.0-py3-none-any.whl.
File metadata
- Download URL: propaganda_pipeline-1.0.0-py3-none-any.whl
- Upload date:
- Size: 70.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
657ffe3d15396a419711f4301503d58bc930ef6715ce42a0584ec301534056c0
|
|
| MD5 |
379fab158a2959f3552427819ba04d28
|
|
| BLAKE2b-256 |
a1690380d3436dfd51a5dbb99ff71d206f632f2949fc99dbc2877fadaac84552
|