Skip to main content

Python SDK for dataset generation on LightningRod platform ⚡

Project description

Lightning Rod Labs

Lightning Rod Python SDK Beta

The Lightning Rod SDK provides a simple Python API for generating custom forecasting datasets to train your LLMs. Transform news articles, documents, and other real-world data into high-quality training samples automatically.

Based on our research: Future-as-Label: Scalable Supervision from Real-World Outcomes

Documentation: docs.lightningrod.ai

👋 Quick Start

1. Install the SDK

pip install lightningrod-ai

2. Get your API key

Sign up at dashboard.lightningrod.ai to get your API key and $50 of free credits.

3. Generate your first dataset

Generate 1000+ forecasting questions in minutes - from raw sources to labeled dataset, automatically. ⚡

from lightningrod import LightningRod, BinaryAnswerType, QuestionPipeline, NewsSeedGenerator, ForwardLookingQuestionGenerator, WebSearchLabeler

lr = LightningRod(api_key="your-api-key")

binary_answer = BinaryAnswerType()

pipeline = QuestionPipeline(
    seed_generator=NewsSeedGenerator(
        start_date=datetime.now() - timedelta(days=90),
        end_date=datetime.now(),
        search_query=["Trump"],
    ),
    question_generator=ForwardLookingQuestionGenerator(
        instructions="Generate binary forecasting questions about Trump's actions and decisions.",
        examples=[
            "Will Trump impose 25% tariffs on all goods from Canada by February 1, 2025?",
            "Will Pete Hegseth be confirmed as Secretary of Defense by February 15, 2025?",
        ]
    ),
    labeler=WebSearchLabeler(answer_type=binary_answer),
)

dataset = lr.transforms.run(pipeline, max_questions=3000)
dataset.flattened()  # Ready-to-use data for your training pipelines

We use this to generate the Future-as-Label training dataset for our research paper.

🆕 New: Foresight-v3 Forecasting Model

We've released foresight-v3, our latest forecasting model. Use it via the OpenAI-compatible API for probability estimates on forecasting questions:

from openai import OpenAI

client = OpenAI(
    api_key="your-api-key",
    base_url="https://api.lightningrod.ai/api/public/v1"
)

response = client.chat.completions.create(
    model="LightningRodLabs/foresight-v3",
    messages=[{"role": "user", "content": "Will the Fed cut rates by 25bp in March 2025?"}]
)
print(response.choices[0].message.content)

See the API docs for full details, or try the Foresight-v3 notebook.

✨ Examples

We have example notebooks to help you get started. If you have trouble using the SDK, please submit an issue on GitHub.

Quick Start

Example Name Path Google Colab Link
Quick Start notebooks/00_quickstart.ipynb Open in Colab

Getting Started

Example Name Path Google Colab Link
News Datasource notebooks/getting_started/01_news_datasource.ipynb Open in Colab
Custom Documents notebooks/getting_started/02_custom_documents_datasource.ipynb Open in Colab
BigQuery Datasource notebooks/getting_started/03_bigquery_datasource.ipynb Open in Colab
Answer Types notebooks/getting_started/04_answer_types.ipynb Open in Colab
GRPO Training notebooks/getting_started/05_grpo_training.ipynb Open in Colab
SFT Training notebooks/getting_started/06_sft_training.ipynb Open in Colab

Custom Filesets

Example Name Path Google Colab Link
Create Fileset notebooks/custom_filesets/01_create_fileset.ipynb Open in Colab
Basic QA Generation notebooks/custom_filesets/02_basic_qa_generation.ipynb Open in Colab
Advanced Features notebooks/custom_filesets/03_advanced_features.ipynb Open in Colab
Beige Book (Document Labeling) notebooks/custom_filesets/04_beige_book.ipynb Open in Colab

Answer Types

Example Name Path Google Colab Link
Binary notebooks/answer_types/binary.ipynb Open in Colab
Continuous notebooks/answer_types/continuous.ipynb Open in Colab
Multiple Choice notebooks/answer_types/multi-choice.ipynb Open in Colab

Evaluation

Example Name Path Google Colab Link
Foresight-v3 Model notebooks/evaluation/01_foresight_model.ipynb Open in Colab
Model Consensus notebooks/evaluation/02_model_consensus.ipynb Open in Colab
Polymarket Backtesting notebooks/evaluation/03_polymarket_backtesting.ipynb Open in Colab
Document Classification notebooks/evaluation/04_document_classification.ipynb Open in Colab

Fine Tuning

Example Name Path Google Colab Link
Golf Forecasting notebooks/fine_tuning/01_golf_forecasting.ipynb Open in Colab
Trump Forecasting notebooks/fine_tuning/02_trump_forecasting.ipynb Open in Colab
Survival LLM notebooks/fine_tuning/03_survival_llm.ipynb Open in Colab
Military Strikes Forecasting notebooks/fine_tuning/04_military_strikes.ipynb Open in Colab

For full documentation, see docs.lightningrod.ai. For the SDK API reference in this repo, see API.md.

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

lightningrod_ai-0.1.23.tar.gz (137.3 kB view details)

Uploaded Source

Built Distribution

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

lightningrod_ai-0.1.23-py3-none-any.whl (265.1 kB view details)

Uploaded Python 3

File details

Details for the file lightningrod_ai-0.1.23.tar.gz.

File metadata

  • Download URL: lightningrod_ai-0.1.23.tar.gz
  • Upload date:
  • Size: 137.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for lightningrod_ai-0.1.23.tar.gz
Algorithm Hash digest
SHA256 7c26cbd99a24232500ccf64c79d6045ae3ba12da2755a4bfd8983e0ca8c46ac0
MD5 42d991a3f609a71b6e723ff3b4da0d25
BLAKE2b-256 3ccafde65097ba3539a421199ef025a2f2f2cebe56847d9c047ad2b56dbbebc9

See more details on using hashes here.

File details

Details for the file lightningrod_ai-0.1.23-py3-none-any.whl.

File metadata

File hashes

Hashes for lightningrod_ai-0.1.23-py3-none-any.whl
Algorithm Hash digest
SHA256 27b2bbb13e8d7f5d4ea4852274ea8dc7e56f6a9116c303a422a1a0e54c1a9436
MD5 9e07c6a4c1bc348350ff67859a2e45d1
BLAKE2b-256 349e85df1c0cc6f4289b190d14a373af65f07d556c567e4c59ee7e575d5c6286

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