I would like to fine-tune a model without having to open the CLI and run commands.
I am trying to make a script that allows users to fine tune models automatically. Is there anything I can do?
My code is
import sqlite3
import os
import time
# Create a connection to the database
conn = sqlite3.connect('database.sqlite')
# Create a cursor
c = conn.cursor()
# Access the database
res = c.execute("SELECT name FROM sqlite_master")
res = res.fetchall()
print(res)
# Ask the user for the table to access
name = input("What expert would you like to access?\nTo make a new one, simply type a name not in the list above\n")
# Use the input to access
if name in [r[0] for r in res]:
print("Expert found.")
else:
try:
c.execute("CREATE TABLE {} (Question TEXT, Response TEXT)".format(name))
print("Expert not found. Created expert instead.")
except sqlite3.OperationalError as e:
print("Error:", e)
time.sleep(1)
def runcode():
os.system('clear')
action = input("What would you like to do?\n Type 1 to add data\n Type 2 to save data\n Type 3 to terminate process\n Type 4 to train and use expert\n")
if action == '1':
addedRequest = input("What would a user ask to request the data?\n")
idealResponse = input("How should the expert respond?\n")
# Use parameterized query to prevent SQL injection
c.execute("INSERT INTO {} (Question, Response) VALUES (?, ?)".format(name), (addedRequest, idealResponse))
runcode()
elif action == '2':
conn.commit()
runcode()
elif action == '3':
print('Goodbye')
elif action == '4':
# I need a way to access the OpenAI CLI here, using the database to fine tune a model in the CLI
print('Not available yet')
runcode()
# Close the connection
conn.close()
“automatically”, and “run commands in a script”, are a bit exclusive.
And also, one can jump from “script” to “program” to GUI application, simply in how complex your “.py” is. You could write a program that is a graphical tune editor and validator, parameter adjuster, submitter, queue tracker, database, chatbot evaluator for validation tests, etc.
Or if you just want to simplify things you can type at a python shell prompt, you could make a module with classes or functions to support fine-tuning:
import my_finetuner as ft
ft.pushtune(model_id, tune_file5.txt)
I would be hard-pressed to offer a solution based on your abstract specifications. If this topic is simply “how do I run external programs from within python”, asking ChatGPT (or a programming forum) is more appropriate.
import sqlite3
import os
import time
# Create a connection to the database
conn = sqlite3.connect('database.sqlite')
# Create a cursor
c = conn.cursor()
# Access the database
res = c.execute("SELECT name FROM sqlite_master")
res = res.fetchall()
print(res)
# Ask the user for the table to access
name = input("What expert would you like to access?\nTo make a new one, simply type a name not in the list above\n")
# Use the input to access
if name in [r[0] for r in res]:
print("Expert found.")
else:
try:
c.execute("CREATE TABLE {} (Question TEXT, Response TEXT)".format(name))
print("Expert not found. Created expert instead.")
except sqlite3.OperationalError as e:
print("Error:", e)
time.sleep(1)
def runcode():
os.system('clear')
action = input("What would you like to do?\n Type 1 to add data\n Type 2 to save data\n Type 3 to terminate process\n Type 4 to train and use expert\n")
if action == '1':
addedRequest = input("What would a user ask to request the data?\n")
idealResponse = input("How should the expert respond?\n")
# Use parameterized query to prevent SQL injection
c.execute("INSERT INTO {} (Question, Response) VALUES (?, ?)".format(name), (addedRequest, idealResponse))
runcode()
elif action == '2':
conn.commit()
runcode()
elif action == '3':
print('Goodbye')
elif action == '4':
# I need a way to access the OpenAI CLI here, using the database to fine tune a model in the CLI
print('Not available yet')
runcode()
# Close the connection
conn.close()
Hello,
Like the other guy said this probably isn’t really the right place to ask this question, not to mention a quick Google search will pop up a quick answer with a lot of examples to use. Or just ask ChatGPT and it can probably write the python script for you.
But to give you a quick answer and at least point you in the right direction I believe you are looking for the exec command in python. i.e exec (/user/bin/hello_world.py).
But there are really much better / safer ways to do what I think you are wanting to do. Doing things like this feels very 90’s.
Check out this answer from Stackoverflow. Execute a command from Python.