Skip to main content

Farsight LLM optimizer

Project description

Revolutionize your prompt engineering with Farsight's OPRO SDK

Stop wasting time with prompt engineering, tailored to your unique inputs and targets, our sdk effortlessly identifies the optimal system prompt for you.

cartoon

Features

  • Python Compatibility: Seamlessly integrates with Python environments.
  • Efficient Prompt Optimization: Streamlines the prompt optimization process in a single step.
  • Automated Testing: Robust testing features for reliability and accuracy.
  • User-Friendly Design: Intuitive and straightforward to use, regardless of your expertise level.

Installation

Install the Farsight OPRO SDK with ease:

pip install farsight-opro

Usage

Dive into the world of optimized prompt engineering with Farsight's OPRO SDK, an implementation inspired by the innovative OPRO paper. Whether you're working on a small project or a large-scale application, our SDK adapts to your needs.

Begin optimizing promptly with this simple setup. For comprehensive guidance, visit our detailed documentation.

from opro import FarsightOPRO

# Define your datasets
dataset = # ...

# Initialize with your OpenAI key
farsight = FarsightOPRO(openai_key=OPEN_AI_KEY)

# Get optimized prompts
prompts_and_scores = farsight.generate_optimized_prompts(dataset)

Full Example:

import json
import random
from sklearn.model_selection import train_test_split
from opro import FarsightOPRO

# replace with your openAI credentials
OPEN_AI_KEY = "<openai_key>"
farsight = FarsightOPRO(openai_key=OPEN_AI_KEY)

# load dataset
dataset_path = "/content/movie_recommendation.json"
with open(dataset_path, "r") as file:
    data = json.load(file)

# split dataset
dataset, test_set = train_test_split(
    data["examples"],
    train_size=0.4
)

##################### For a short test run, try this #####################

# dataset = [
#     {'input': 'Find a movie similar to Batman, The Mask, The Fugitive, Pretty Woman:\nOptions:\n(A) The Front Page\n(B) Maelstrom\n(C) The Lion King\n(D) Lamerica','target': '(C)'},
#     {'input': 'Find a movie similar to The Sixth Sense, The Matrix, Forrest Gump, The Shawshank Redemption:\nOptions:\n(A) Street Fighter II The Animated Movie\n(B) The Sheltering Sky\n(C) The Boy Who Could Fly\n(D) Terminator 2 Judgment Day', 'target': '(D)'},
#     {'input': "Find a movie similar to Schindler's List, Braveheart, The Silence of the Lambs, Tombstone:\nOptions:\n(A) Orlando\n(B) Guilty of Romance\n(C) Forrest Gump\n(D) All the Real Girls", 'target': '(C)'},
#  ]
# prompts_and_scores = farsight.generate_optimized_prompts(dataset, prompts_generated_per_iteration=2, num_iterations=3)
# print(prompts_and_scores)

########################################################################


# get optimized prompts
prompts_and_scores = farsight.generate_optimized_prompts(dataset, test_set)
print(prompts_and_scores) 
#  [{
#        "prompt": "Choose the movie option that aligns with the given movies' genres, popularity, critical acclaim, and overall quality to provide the most accurate and comprehensive recommendation."
#        "score": 0.94,
#        "test_score": 0.88
#
#   },
#   {
#        "prompt": "Choose the movie option that aligns with the genres, themes, popularity, critical acclaim, and overall quality of the given movies to provide the most accurate and comprehensive recommendation."
#        "score": 0.9,
#        "test_score": 0.86
#   }, ...

Contributing

Bug Reports & Feature Requests

Encounter an issue or have an idea? Share your feedback on our issue tracker.

Development Contributions

Your contributions are welcome! Join us in refining and enhancing our prompt optimization library.

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

farsight-opro-0.2.14.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

farsight_opro-0.2.14-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file farsight-opro-0.2.14.tar.gz.

File metadata

  • Download URL: farsight-opro-0.2.14.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for farsight-opro-0.2.14.tar.gz
Algorithm Hash digest
SHA256 2636a678f5f933cf31ed61d32a1530c47724133368be3a606c53f317c40e15b3
MD5 7eaf0d0816d6647a3d7d2539d5ae6d2f
BLAKE2b-256 d42d6e93a5b1312ae87b65c570d3f16658eca3d43254d978031a74d9c73f352c

See more details on using hashes here.

File details

Details for the file farsight_opro-0.2.14-py3-none-any.whl.

File metadata

File hashes

Hashes for farsight_opro-0.2.14-py3-none-any.whl
Algorithm Hash digest
SHA256 7f52bd7beded94c4b16b57d6207a5bafe5d1ac63335a8efd88607818a5726792
MD5 c9e1db7f1abb86790cd8a5349f16e7c9
BLAKE2b-256 3f528e6d0a03186a690cbd4f7b187f568834dbc4176ff07f3c1af5338b209565

See more details on using hashes here.

Supported by

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