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(binary_answer)  # 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 some example notebooks to help you get started! If you have trouble using the SDK, please submit an issue on Github.

Tutorials

Example Name Path Google Colab Link
Quick Start notebooks/01_quick_start.ipynb Open in Colab
News Datasource notebooks/02_news_datasource.ipynb Open in Colab
Custom Documents notebooks/03_custom_documents_datasource.ipynb Open in Colab
Binary Answer Type notebooks/04_binary_answer_type.ipynb Open in Colab
Continuous Answer Type notebooks/05_continuous_answer_type.ipynb Open in Colab
Multiple Choice Answer Type notebooks/06_multiple_choice_answer_type.ipynb Open in Colab
Free Response Answer Type notebooks/07_free_response_answer_type.ipynb Open in Colab
BigQuery Datasource notebooks/08_bigquery_datasource.ipynb Open in Colab
Foresight-v3 Model notebooks/09_foresight_model.ipynb Open in Colab

End-to-end

Example Name Path Google Colab Link
Golf Forecasting notebooks/e2e/golf_forecasting.ipynb Open in Colab
Trump Forecasting notebooks/e2e/trump_forecasting.ipynb Open in Colab
Document Classification notebooks/e2e/document_classification.ipynb Open in Colab
Polymarket Backtesting notebooks/e2e/polymarket_backtesting.ipynb Open in Colab
Model Consensus notebooks/e2e/model_consensus.ipynb Open in Colab
Survival LLM notebooks/e2e/survival_llm.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.17.tar.gz (95.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.17-py3-none-any.whl (208.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for lightningrod_ai-0.1.17.tar.gz
Algorithm Hash digest
SHA256 211070950acc15411989714fc509816394471998b0767c35a0de85b3bdb67d3a
MD5 a30b99b07a18c0a8a4a6f734da87c7d4
BLAKE2b-256 baf3d5e75e996c7535d98b4f95805519fb48369170c5902131c619da04b78c3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightningrod_ai-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 34d03b71022b3c70fa621a0db6d24d2a49f461dab815bbc9e71c0e5e1443a47c
MD5 a580d6182c4af1e5ec04f0c3ae2d77a1
BLAKE2b-256 f8ab24fd170a83e0b82d191a6a7d098dbdff6cdb75c436879df1881c32272281

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