Skip to main content

Opticonomy Prompt Driven Model Evaluation (PDME)

Project description

Opticonomy Prompt Driven Model Evaluation (PDME)

Overview

The method uses a single text generation AI, referred to as eval model, to evaluate any other text generation AI on any topic, and the evaluation works like this:

  1. We write a text prompt for what questions the eval model should generate, and provide seeds that are randomly picked to generate a question.
  2. The question is sent to the AI model being tested, and it generates a response.
  3. Likewise, the eval model also generates an answer to the same question.
  4. The eval model then uses a text prompt we write, to compare the two answers and pick the winner.

This method allows us to evaluate models for any topic, such as: storytelling, programming, finance, and QnA.

Installation

Install Package

pip install opticonomy-pdme

Create and Activate the Virtual Environment

  • Set up a Python virtual environment and activate it (Linux):

    python3 -m venv .venv
    source .venv/bin/activate
    
  • Set up a Python virtual environment and activate it (Windows/VS Code / Bash):

    python -m venv venv
    source venv/Scripts/activate
    
  • Install dependencies from the requirements.txt file:

    pip install -r requirements.txt
    

Running Sample Use Cases

Storytelling

  • Run the following:
python examples/storytelling_example.py
  • Sample output:
INFO:opti_pdme.opticonomy_pdme:Generated text: Model 1's response is well-crafted and provides a fitting continuation to the original story. It successfully maintains the narrative's tone and theme, while also expanding on Amelia's journey and relationship with Faelan. Here's a summary of why Model 1's response stands out:

1. **Character Development**:
  - The response deepens Amelia's character by showing her growth and her impact on the academic world.
  - It continues to explore the bond between Amelia and Faelan, adding emotional depth to their friendship.

2. **Plot Progression**:
  - The storyline progresses naturally, introducing a new layer of responsibility for Amelia as the guardian of the ChronoSphere.
  - Faelan's reappearance provides a satisfying closure to their relationship, while also setting up a new chapter in Amelia's life.

3. **Themes and Motifs**:
  - The response stays true to the original themes of time, knowledge, and interconnectedness.
  - It introduces the idea of guardianship and the responsibility that comes with great knowledge.

4. **Imagery and Descriptive Language**:
  - The use of descriptive language helps to create vivid imagery, making the scenes more immersive.
  - The serene evening in Central Park and the timeless forest are particularly well-described, enhancing the reader's visual experience.

5. **Emotional Resonance**:
  - The reunion between Amelia and Faelan is emotionally satisfying, reinforcing the bond they share.
  - The ending leaves a lasting impression, highlighting the importance of friendship and wisdom across time.

Overall, Model 1 effectively builds on the original story, providing a rich and engaging continuation that honors the spirit of the narrative while adding new dimensions to it.
INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
INFO:opti_pdme.opticonomy_pdme:Label:  1, LogProb: -0.00043698703, Logit: 7.735388541471373, Prob: 0.999563108434926
INFO:opti_pdme.opticonomy_pdme:Label:  2, LogProb: -1.1279553e-05, Logit: 11.392513300559003, Prob: 0.9999887205106139
INFO:opti_pdme.opticonomy_pdme:Final normalized probabilities: [0.49989357313235727, 0.5001064268676427]
INFO:opti_pdme.opticonomy_pdme:Probability for 'openai/gpt-4o': 0.49989357313235727
INFO:opti_pdme.opticonomy_pdme:Probability for 'openai-community/gpt2': 0.5001064268676427
INFO:opti_pdme.opticonomy_pdme:Result: 'openai-community/gpt2' is better
INFO:__main__:Evaluation result: 'openai-community/gpt2' is better
INFO:__main__:Probabilities: [0.49989357313235727, 0.5001064268676427]

Coding

  • Run the following:
python examples/coding_example.py
  • Sample output:
...
### Explanation

1. **`validate_tic_tac_toe(board)`**:
  - This function checks each row, column, and diagonal for a winner.
  - If there's a winner, it returns either `'X wins'` or `'O wins'`.
  - If there are empty cells but no winner, it returns `'Ongoing'`.
  - If the board is full and there's no winner, it returns `'Draw'`.

2. **`sort_game_states(game_states)`**:
  - This function uses a custom sorting key that first checks the game state.
  - It then sorts by the count of 'X's and 'O's.
  - The sorting key is a tuple that prioritizes the game state, followed by the count of 'X's, and then the count of 'O's.

### Conclusion

This solution efficiently validates and sorts Tic-Tac-Toe game states. It checks all necessary conditions for the game state and sorts the boards based on the predefined criteria. The code is modular, making it easy to understand and maintain.
INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
INFO:opti_pdme.opticonomy_pdme:Label:  1, LogProb: -1.9361265e-07, Logit: 15.4574062265043, Prob: 0.9999998063873687
INFO:opti_pdme.opticonomy_pdme:Label:  2, LogProb: -1.8624639e-06, Logit: 13.193609338205482, Prob: 0.9999981375378344
INFO:opti_pdme.opticonomy_pdme:Final normalized probabilities: [0.5000004172128125, 0.4999995827871875]
INFO:opti_pdme.opticonomy_pdme:Probability for 'openai/gpt-4o': 0.5000004172128125
INFO:opti_pdme.opticonomy_pdme:Probability for 'openai-community/gpt2': 0.4999995827871875
INFO:opti_pdme.opticonomy_pdme:Result: 'openai/gpt-4o' is better
INFO:__main__:Evaluation result: 'openai/gpt-4o' is better
INFO:__main__:Probabilities: [0.5000004172128125, 0.4999995827871875]

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

opticonomy-pdme-0.1.5.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

opticonomy_pdme-0.1.5-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file opticonomy-pdme-0.1.5.tar.gz.

File metadata

  • Download URL: opticonomy-pdme-0.1.5.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for opticonomy-pdme-0.1.5.tar.gz
Algorithm Hash digest
SHA256 85b89d78a93ee3bf38e7b955e3452a0d11a5365f3da4a4a08aa6123c08232d97
MD5 606c0d4076ccc4fd1472afb56c92df9f
BLAKE2b-256 ded923160f0c8ededfc3a2b74dc0177ea9be1872bc5695363983f1e16fa24845

See more details on using hashes here.

File details

Details for the file opticonomy_pdme-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for opticonomy_pdme-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6f82b4e4308950bf2dd7c1f05999d7a5bf66b7aa4e57d4d9b1ddbb72badecd5b
MD5 797573089ea991e0a42834034c638d9b
BLAKE2b-256 d3056c86e2fb778ef5053e88d736e4b06be307e6cbc11ecb99649065d53bb15b

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