Skip to main content

Packaged with Poetry Code style: black Coverage

GPTagger :label:

GPT Tagger is a powerful text tagger that makes use of the GPT model. This tool allows you to extract tags from a given text by leveraging the capabilities of GPT. However, using GPT as a text tagger is not a trivial task. GPT has the tendency to generate non-existing, fabricated, or processed text. To mitigate this issue, GPT Tagger provides a reliable method to ensure that the generated tags are derived from the input text while allowing GPT to process the extracted tags to some extent.

Below is an example of how GPT may respond wrong.

Text: "I earn $1000 this week!"
Prompt: "Extract how much he/she earns"

# Non-existent text
GPT: "one thousand dollar"
# Make-up text
GPT: "$999999"
# Processed text
GPT: "$1,000"

Introduction

GPTagger Demo

These incorrect responses highlight the importance of using a reliable tag extraction tool like GPT Tagger. To do that, GPT Tagger follows a set of main steps:

  1. 🕵️‍♀️ Extraction: GPT Tagger sniffs out all possible tags by following your instructions to GPT.
  2. 🔍 Indexing: It spots the exact locations of these tags within the text.
  3. ✅ Validator: GPT Tagger's trusty validator steps in to validate if the extracted tags pass the rule-based and ML-based checks.

Check the example above how we extract ingredients from a yummy recipe text. 😋

Features ✨

Scale up GPT annotators and use switch between GPT3.5 and GPT4 easily

  • Want to have a higher precision? try using GPT-4!
  • Want to have a higher recall? Scale up the number of GPT annotators!

Instead of making a perfect prompt, use validator to shave off bad extractions

  • Simple validator: Length, Regex...
  • ML validator: GPT validator (Consider it like a chain of GPTs!)

How to Use 🚀

Setup

make install
export OPENAI_API_KEY=<your-key>

Pre-defined NER pipeline

The easiest way to dive into the GPT Tagger is through the Gradio web demo! Fire it up with a single command:

poetry run python GPTagger/app.py

If you prefer having the power of GPT Tagger at your fingertips in Python, check out this snippet:

from pathlib import Path
from GPTagger import *

cfg = NerConfig(
    tag_name='date',
    tag_regex=r"\d",
    tag_max_len=128,
)
prompt = PromptTemplate.from_template(Path('<path-to-prompt>').read_text())
pipeline = NerPipeline.from_config(cfg)

doc = Path('<path-to-doc>').read_text()
tags = pipeline(doc, prompt)

Build Custom Pipelines 🎉

We believe that the possibilities of using GPT as a text tagger are endless! We invite you to contribute your own custom pipelines. Together, we'll unlock the true potential of GPT Tagger and make text tagging an better experience.

Leave a star if you find GPTagger is useful for your product or company! 🌟

Metadata

Release files for gptagger 0.0.2

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

Source distribution (sdist)

Source distribution for gptagger 0.0.2
File Size Uploaded
gptagger-0.0.2.tar.gz 22.2 kB Details

Built distribution (wheel)

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

Total release size: 48.1 kB

Release files / gptagger-0.0.2.tar.gz

Download URL gptagger-0.0.2.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
eb4854585ac6f3c6f06aa57d135ce9d12d7e33b762e5808ecc39627167d935ed
BLAKE2b-256 checksum
How to use checksums
d8edae733ae1c4c5bc07692ddac658a4c7b9acc10a0b147987cb825ad1d55c9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.0 CPython/3.9.9 Darwin/21.6.0

Release files / gptagger-0.0.2-py3-none-any.whl

Download URL gptagger-0.0.2-py3-none-any.whl
Size 25.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52eca80cab8de4f2e9ea27b8ea8605614c0c4f7129883dde8242dfa30447bf1d
BLAKE2b-256 checksum
How to use checksums
52d6654cd8ade5c195653e85c9a6fbb792ad3fa711c50319258f65f4b4c959f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.0 CPython/3.9.9 Darwin/21.6.0

Release history Release notifications | RSS feed

This release

0.0.2 This release

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