Skip to main content

A package for simplified and reproducible LLM prompting.

Project description

RadPrompter

RadPrompter

RadPrompter is a Python package for simplified and reproducible LLM prompting, particularly tailored for biomedical applications, including Radiology.

Installation

You can install RadPrompter using pip:

pip install radprompter

Note: RadPrompter works with Python 3.7+. However, for maximum compatilibity we recommend using Python 3.11+.

Getting Started

The core of RadPrompter is the .toml configuration file which defines your prompts. Here's a minimal example:

[METADATA]
version = 0.1
description = "A sample prompt for RadPrompter"

[CONSTRUCTOR]
system = "You are an experienced radiologist that help users extract infromation from radiology reports."
user = """Does the following report indicate a normal or abnormal finding?
{{report}}

Just reply with "normal" or "abnormal" to indicate your answer, without any additional information.
"""

And here's how you would use it in Python:

from radprompter import Prompt, RadPrompter, vLLMClient

prompt = Prompt("sample.toml")

client = vLLMClient(
    model="google/medgemma-4b-it",
    base_url="http://localhost:8000/v1",
    temperature=0.0,
    seed=42
)

engine = RadPrompter(
    client=client,
    prompt=prompt, 
    output_file="output.csv",
)

reports = [{"report": "..."}]  # Your radiology reports
engine(reports)

For more details and advanced usage, check out our tutorials.

Tutorials

Tutorial Description Notebook
01_Basic-Usecase Covers the basic usage of RadPrompter 👁️ 📓
02_RDP-Templating Introduces the [PROMPTS] section and rdp operator 👁️ 📓
03_Multiturn-Prompting Demonstrates multi-turn prompting 👁️ 📓
04_Using-Schemas Shows how to use schemas for structured output 👁️ 📓
05_JSON-Prefill Covers using JSON prefills and sanitization 👁️ 📓
06_HuggingFace-Client Covers using the new HuggingFaceClient 👁️ 📓
07_Conditional-Schemas Demonstrates how to use conditional schemas (v2.0+) 👁️ 📓

Contributing

We welcome contributions! If you have any updates or improvements to the package, please open an issue or submit a pull request. We're happy to review and incorporate your changes.

Authors

RadPrompter is created and maintained by:

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

radprompter-2.0.0.tar.gz (145.6 kB view details)

Uploaded Source

Built Distribution

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

radprompter-2.0.0-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file radprompter-2.0.0.tar.gz.

File metadata

  • Download URL: radprompter-2.0.0.tar.gz
  • Upload date:
  • Size: 145.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for radprompter-2.0.0.tar.gz
Algorithm Hash digest
SHA256 95167f7e8dc1ea2caab7059bec40982502061929cafd76ac1746ce048b8c67a7
MD5 3fcb7e6c51f7d9874d7e45851a6acd37
BLAKE2b-256 590cb11d6835fb0a4b791b2081096ba3c0fe254d158338478aa29a7acbb71d99

See more details on using hashes here.

File details

Details for the file radprompter-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: radprompter-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for radprompter-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03366fc4a3b0417b83a67fe6821d4602e667ad11a56c72e91092e35962e358b9
MD5 3b92dafcbcaa55bfe2778a340ab61162
BLAKE2b-256 1f6e5c12c56aa9af800e206017c0079d52e36831ff593a1238841f140de3169d

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