Skip to main content

A Python library for classification tasks using multiple LLMs

Project description

PCS Annotator: A Python Library for Classification Tasks Using Multiple LLMs

How to Install

pip install pcs-annotator

How to Use

from pcs_annotator import PCS

Create a Prompt for Classification Tasks

prompt = """Analyze the news article and determine whether it is 'Fake' or 'Real.'
Label the article using the tag format: <label>Fake</label> or <label>Real</label>.
Afterward, provide your reasoning after the “<reasoning>” tag and close it with "</reasoning>".
Respond only with the label and the reasoning.
"""

Training Dataset Path (dataset_path)

You will need a CSV file with two columns: label and text to ensure better annotation, as the data is used to train the LLMs.

🔧 Customizing Hyperparameters

The PCS class allows you to customize various hyperparameters, including the choice of annotator models, text mutator models, and API keys for different LLM providers.

📌 Example Usage

pcs = PCS(
    prompt="Your classification prompt here",
    dataset_path="path/to/dataset.csv",
    annotators=["llama3-8b-8192", "mistralai/Mistral-7B-Instruct-v0.3", "google/gemma-2-9b-it"],
    textmutator="llama-3.1-8b-instant",
    GROQ_API_KEY=None,
    OPENAI_API_KEY=None,
    ANTHROPIC_API_KEY=None,
    HUGGINGFACE_API_KEY=None,
    train=True
)

print(pcs.annotate("America is a country"))

Configuration

🔹 Annotators (annotators)

Defines the list of LLMs used for annotation.

  • Default Models:
    • "llama3-8b-8192"
    • "mistralai/Mistral-7B-Instruct-v0.3"
    • "google/gemma-2-9b-it"
  • Customization:
    • You can add, remove, or modify the annotators by passing a list of model names.

🔹 Text Mutator (textmutator)

Determines the LLM used for generating text mutations.

  • Default Model: "llama-3.1-8b-instant"
  • Customization:
    • You can replace it by passing a different model name as a string.

🔹 API Keys

To access certain LLM models, you need to provide API keys. These can be passed as arguments during initialization or set as environment variables in a .env file.

API Key Purpose
GROQ_API_KEY Required for Llama models. Set via argument or .env file.
OPENAI_API_KEY Required for OpenAI models (e.g., "gpt-4").
ANTHROPIC_API_KEY Required for Anthropic models (e.g., "claude-3-5-sonnet-20241022").
HUGGINGFACE_API_KEY Required for Mistral and Google Gemma models.

🔹 Continue the Training (train)

Determines whether to continue optimizing weights using more data or not

  • Default Value: True
  • Customization:
    • You can change to False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pcs_annotator-0.1.15.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pcs_annotator-0.1.15-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file pcs_annotator-0.1.15.tar.gz.

File metadata

  • Download URL: pcs_annotator-0.1.15.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pcs_annotator-0.1.15.tar.gz
Algorithm Hash digest
SHA256 b01f6d61ff54b66eb97553b3866e1cb9ed658fa716d5b37f0ca14cfb61aefc93
MD5 0789692835e65f1f417fd676a2e5c7b3
BLAKE2b-256 233d1301ed5bc2804d79dfb320946392818d8b9a3244b86246fbbbe2ee2bc3db

See more details on using hashes here.

File details

Details for the file pcs_annotator-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: pcs_annotator-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pcs_annotator-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 9734aeca1805215bff1c912f7979fe319742b4bf261b2361ec05e7d8fce0e0f0
MD5 0dc3883a2f4c796d6168bf3f4ef804e0
BLAKE2b-256 e8043bd8afce898f9ec468761712e0bd2fb37bd36a70ea761836bfa328e8adab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page