Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create run.py #1204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import os

# Llama ASCII art
print("""
▓▓ ▓▓
▓▓░░▓▓░░▓▓
▓▓▓▓░░░░░░▓▓
▓▓░░░░░░██░░▓▓
▓▓░░░░░░░░░░▓▓
▓▓▓▓░░░░░░▓▓
▓▓░░░░▓▓
▓▓░░░░▓▓ ▓▓
▓▓░░░░▓▓ ▓▓░░▓▓
▓▓░░░░▓▓ ▓▓░░▓▓
▓▓░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░▓▓
▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓
▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓
▒▒░░░░░░░░░░░░░░░░░░░░░░▒▒
▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓
▓▓░░░░░░░░░░░░░░░░░░▓▓
▓▓▒▒▒▒░░▓▓▓▓▒▒▒▒▒▒░░▓▓
▓▓░░▓▓░░▓▓ ▓▓░░▓▓░░▓▓
▓▓░░▓▓░░▓▓ ▓▓░░▓▓░░▓▓
▓▓░░▓▓░░▓▓ ▓▓░░▓▓░░▓▓
▓▓░░▓▓░░▓▓ ▓▓░░▓▓░░▓▓
▓▓░░▒▒░░▒▒ ▒▒░░▓▓░░▓▓
░░▒▒ ▒▒░░ ▒▒░░▒▒

""")
print("Welcome to the Llama.cpp\n")


# Set the directory to search in
dir_path = "./models/"

# Initialize a list to store the paths of all .bin files found
bin_files = []

# Traverse the directory and its subdirectories to find all .bin files
for root, dirs, files in os.walk(dir_path):
for file in files:
if file.endswith(".bin"):
bin_files.append(os.path.join(root, file))

# Print the list of .bin files found
print("Choose a file:")
for i, file in enumerate(bin_files):
print(f"{i+1}. {file}")

# Ask the user to choose a file by entering its number
while True:
try:
choice = int(input("Enter the number of the file you want to choose: "))
if choice < 1 or choice > len(bin_files):
raise ValueError
break
except ValueError:
print("Invalid choice. Please enter a number between 1 and", len(bin_files))

# Get the path of the chosen file
chosen_file_path = bin_files[choice-1]

# Ask the user for the CTX size
ctx_size = input("Enter the CTX size (default is 2048): ")

# Set the default CTX size to 2048 if no answer is provided
if not ctx_size:
ctx_size = "2048"

# Ask the user for the Top K
top_k = input("Enter the Top K (default is 10000): ")

# Set the default Top K to 10000 if no answer is provided
if not top_k:
top_k = "10000"

# Ask the user for the Repeat Penalty
repeat_penalty = input("Enter the Repeat Penalty (default is 1): ")

# Set the default Repeat Penalty to 1 if no answer is provided
if not repeat_penalty:
repeat_penalty = "1"

# Do something with the chosen file, CTX size, Top K, and Repeat Penalty...


# Ask the user for the temperature
temperature = input("Enter the temperature (between 0 and 2, default is 0.2): ")
if not temperature:
temperature = "0.2"
else:
try:
temperature = float(temperature)
except ValueError:
print("Invalid temperature. Using default value of 0.2")
temperature = "0.2"
else:
if temperature < 0 or temperature > 2:
print("Invalid temperature. Using default value of 0.2")
temperature = "0.2"




os.system(f"./main -m {chosen_file_path} --color -f ./prompts/alpaca.txt --ctx_size {ctx_size} -n -1 -ins -b 256 --top_k {top_k} --temp {temperature} --repeat_penalty {repeat_penalty} -t 7")