Skip to main content

The Generalized Attribute Based Ratings Information Extraction Library (GABRIEL)

Description

GABRIEL is a simple Python framework built on top of LLMs like ChatGPT to simplify quantitative text analysis in the social sciences.

IMPORTANT: Follow this Colab tutorial notebook for the easiest setup guide: https://colab.research.google.com/drive/1tshfY-2al7asU7pTFvFFg1n4NSvLXtZg?usp=sharing

The full documentation is below.

Installation

The new Python library replaces the previous API and dramatically simplifies the use of the package. Installation is extremely simple using pip.

Before you install our package, we require that you install the OpenAI library. Open your terminal or command prompt and run:

pip install openai

Once you have installed OpenAI, install GABRIEL using

pip install gabriel-ratings

Use

Simple ratings framework

The main way to get ratings from GABRIEL is using the Archangel class. The class requires an OpenAI api-key for instantiation. We strongly recommend you store the key as an environment variable. To create an Archangel object, use the following syntax.

from GABRIEL.Archangel import Archangel
combined_assistant = Archangel(your_api_key)

Once you create the object, you can run a simple ratings framework through the rate_texts function. You must supply a list of the texts to rate, texts; an attributes_dict, where the keys are your attributes, and the values are the definitions, and a task_description, which is a few sentence description of what you're trying to acccomplish (your data, your question, etc.). In addition, we require a save_folder and a file_name, which is where the output from your run will be saved.

You can also specify a specific OpenAI model for your call, using the model parameter (the default is GPT-3.5-turbo). See below for the full list of parameters, and more detailed descriptions.

The simplest ratings call, which returns a Pandas dataframe, is just:

ratings = archangel.rate_texts(texts, attribute_dict= attribute_dict, save_folder = 'path_to_your_folder', file_name = 'your_file_name.csv', task_description = 'your_task_description')

Features

The Archangel class comes with a number of easy to use features to help you run your code.

  • parallelization: the library parallelizes API calls to dramatically speed up running time. We configure this by default.
  • cost estimates: we provide a very rough cost estimate of each run when you begin the call, based on the model and texts you input.
  • auto-saving: the class will auto-save your results to a CSV at each iteration, as long as you provide a valid path.

Preset classes

To simplify the task of choosing your hyperparameters, we provide two default options:

  • 'mazda': cheap, fast, and reliable. Uses GPT-3.5-turbo, with text truncation to 9500 words to allow for prompts. Runs 50 queries in parallel.
  • 'tesla': expensive. Uses GPT-4-turbo, with 30 parallel queries. Not recommended due to cost.

Function parameters

The full list of parameters for the function is as follows.

  • attribute_dict A dictionary where the keys are the attributes you want to evaluate, and the values are the descriptions. See Colab notebook for examplse.
  • truncate (optional, defaults to True): Whether to truncate the text. This avoids overloading the API token limit (16k tokens for the default model). -truncate_len (optional, defaults to 5000) the amount of text to keep.
  • project_probs (optional, defaults to False): Whether to project the probabilities from 0 to 100 to a 0 to 1 scale.
  • api_key (mandatory): Your OpenAI API key.
  • model (optional): Backend model, default = gpt-3.5-turbo-1106.
  • seed (optional, RECOMMENDED): Set a seed for cross-run replicability. For instance, seed = 0.

Citation

Please cite the project using:

The Generalized Attribute Based Ratings Information Extraction Library (GABRIEL). Hemanth Asirvatham and Elliott Mokski (2023). https://github.com/elliottmokski/GABRIEL-distribution.

Release files for GABRIEL-ratings 2.0.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 GABRIEL-ratings 2.0.3
File Size Uploaded
gabriel_ratings-2.0.3.tar.gz 46.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for GABRIEL-ratings 2.0.3
File Interpreter ABI Platform
GABRIEL_ratings-2.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 96.2 kB

Release files / gabriel_ratings-2.0.3.tar.gz

Download URL gabriel_ratings-2.0.3.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
04779d91712543ba95613f986183b75a539a010726b57323b4246aa549df87cf
BLAKE2b-256 checksum
How to use checksums
be5352e0f476187b5db49abda254a69c477fe7b60ee7054267f1829eb3897411
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.5

Release files / GABRIEL_ratings-2.0.3-py3-none-any.whl

Download URL GABRIEL_ratings-2.0.3-py3-none-any.whl
Size 49.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d332620a89044089ebaa7299594856ce2c97d0a42690299d8135366dd8295064
BLAKE2b-256 checksum
How to use checksums
75483564cef5e22527740a3901d257aec369c59d9f6b2fd1bb2dd5f5cb8d2c98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

2.0.3 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.0

2 release files

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