Skip to main content

large language model Programming - Type safe structured generation

Project description

Large Language Model Programming (LLMP)

LLMP provides a high-level abstraction for creating, storing, and optimizing generative NLP tasks. It leverages the power of large language models, enabling users to seamlessly integrate them into their software projects without the hassle of manually crafting and optimizing prompts.

Key Features

  • Job Creation: Define jobs using input and output object structures.
  • Auto-Optimization: LLMP automatically optimizes prompts to achieve desired outputs.
  • Metrics Collection: Evaluate the performance of prompts in terms of accuracy, efficiency, and cost.
  • Storage Management: Jobs are organized and stored systematically for easy retrieval and management.

Documentation and Examples

For detailed documentation and examples, please refer to the:

Quick Start

Installation

pip install pyllmp

Creating a Job

from pydantic import BaseModel
from typing import Literal
from llmp.services.program import Program

class InputObject(BaseModel):
    book_title: str
    book_author: str
    release_year: int

class OutputObject(BaseModel):
    genre: Literal["fiction", "non-fiction", "fantasy", "sci-fi", "romance", "thriller", "horror", "other"]

# Initialize a job
program = Program("Book to Genre", input_model=InputObject, output_model=OutputObject)

Loading a Job

program = Program("Book to Genre")

Running a Job

After creating or loading a job, you can easily execute it with input data to get the desired output.

input_data = {
    "book_title": "The Lord of the Rings",
    "book_author": "J. R. R. Tolkien",
    "release_year": 1954
}

result = program(input_data=input_data)
print(result)

Output:

{
    "genre": "fantasy"
}

Monitoring a Job

To monitor existing jobs, you can use the streamlit command-line tool to run the monitoring application. Navigate to the libs/llmp-monitor directory and run the following command:

streamlit run app.py

Here you can past your local job directory path to monitor, update and optimize jobs located in that directory. Once you have run the command and entered the path, you can access the monitoring application at http://localhost:8501. You should see a screen similar to the following:

App Screenshot

Architecture

LLMP follows a component-based architecture with service layers, ensuring modularity and scalability. For detailed insights into the architecture, refer to the project documentation.

Contribute

LLMP is an open-source project. Contributions, feedback, and suggestions are welcome! Please check out the CONTRIBUTING.md guide for more details.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

pyllmp-0.0.14.tar.gz (137.2 kB view details)

Uploaded Source

Built Distribution

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

pyllmp-0.0.14-py3-none-any.whl (104.3 kB view details)

Uploaded Python 3

File details

Details for the file pyllmp-0.0.14.tar.gz.

File metadata

  • Download URL: pyllmp-0.0.14.tar.gz
  • Upload date:
  • Size: 137.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for pyllmp-0.0.14.tar.gz
Algorithm Hash digest
SHA256 6d272f9ce46a81426a9eeb3e7fc39d74160906b97c71b48b642ffc90adc36872
MD5 6a55547dae02c2941f237c08824f3827
BLAKE2b-256 cc7fad352f15b08ebd4db760bb085e0055caf41b1448b1f8cf34caa4ed5b8a8c

See more details on using hashes here.

File details

Details for the file pyllmp-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: pyllmp-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 104.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for pyllmp-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 befc59667ca52b4948c817a527916df3930e93e8d6fbded49ced07cde9507e07
MD5 0ccccf733c85b6d6222b9b196bdc41e1
BLAKE2b-256 a1923a0d4136ddc9a4a6149e23f567899f705865b044bf5cec6d7bc7b226e404

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