Download add_output_input_multiple.py from danielrosehill/Agentic-LLM-Price-Comparisons: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/danielrosehill/Agentic-LLM-Price-Comparisons/resolve/main/add_output_input_multiple.py
- Command line
-
hf download hf://spaces/danielrosehill/Agentic-LLM-Price-Comparisons/add_output_input_multiple.py
-
curl -L -o add_output_input_multiple.py https://huggingface.co/spaces/danielrosehill/Agentic-LLM-Price-Comparisons/resolve/main/add_output_input_multiple.py
1.53 kB
| #!/usr/bin/env python3 | |
| """ | |
| Add output/input price multiple to the quadrants CSV. | |
| This calculates how many times more expensive output tokens are compared to input tokens. | |
| """ | |
| import pandas as pd | |
| # Read the CSV | |
| df = pd.read_csv('quadrants.csv') | |
| # Calculate output/input multiple | |
| # Handle edge cases where input price might be 0 (shouldn't happen, but be safe) | |
| df['output_input_multiple'] = df.apply( | |
| lambda row: row['output_price_usd_per_m'] / row['input_price_usd_per_m'] | |
| if row['input_price_usd_per_m'] > 0 else 0, | |
| axis=1 | |
| ) | |
| # Save updated CSV | |
| df.to_csv('quadrants.csv', index=False) | |
| # Calculate and display statistics | |
| median_multiple = df['output_input_multiple'].median() | |
| mean_multiple = df['output_input_multiple'].mean() | |
| min_multiple = df['output_input_multiple'].min() | |
| max_multiple = df['output_input_multiple'].max() | |
| print(f"Output/Input Price Multiple Statistics:") | |
| print(f" Median: {median_multiple:.2f}x") | |
| print(f" Mean: {mean_multiple:.2f}x") | |
| print(f" Min: {min_multiple:.2f}x") | |
| print(f" Max: {max_multiple:.2f}x") | |
| print(f"\nTotal models: {len(df)}") | |
| print(f"\nModels by output/input multiple:") | |
| print(f" 1x (equal pricing): {len(df[df['output_input_multiple'] == 1])}") | |
| print(f" <2x: {len(df[df['output_input_multiple'] < 2])}") | |
| print(f" 2-5x: {len(df[(df['output_input_multiple'] >= 2) & (df['output_input_multiple'] < 5)])}") | |
| print(f" 5-10x: {len(df[(df['output_input_multiple'] >= 5) & (df['output_input_multiple'] < 10)])}") | |
| print(f" 10x+: {len(df[df['output_input_multiple'] >= 10])}") | |