forked from ggerganov/llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,092 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,5 @@ zig-out/ | |
zig-cache/ | ||
|
||
ppl-*.txt | ||
|
||
examples/jeopardy/results.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# llama.cpp/example/jeopardy | ||
|
||
This is pretty much just a straight port of aigoopy/llm-jeopardy/ with an added graph viewer. | ||
|
||
The jeopardy test can be used to compare the fact knowledge of different models and compare them to eachother. This is in contrast to some other tests, which test logical deduction, creativity, writing skills, etc. | ||
|
||
|
||
Step 1: Open jeopardy.sh and modify the following: | ||
``` | ||
MODEL=(path to your model) | ||
MODEL_NAME=(name of your model) | ||
prefix=(basically, if you use vicuna it's Human: , if you use something else it might be User: , etc) | ||
opts=(add -instruct here if needed for your model, or anything else you want to test out) | ||
``` | ||
Step 2: Run `jeopardy.sh` from the llama.cpp folder | ||
|
||
Step 3: Repeat steps 1 and 2 until you have all the results you need. | ||
|
||
Step 4: Run `graph.py`, and follow the instructions. At the end, it will generate your final graph. | ||
|
||
Note: The Human bar is based off of the full, original 100 sample questions. If you modify the question count or questions, it will not be valid. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import matplotlib.pyplot as plt | ||
import sys, os | ||
import csv | ||
|
||
labels = [] | ||
numbers = [] | ||
numEntries = 1 | ||
|
||
rows = [] | ||
|
||
def bar_chart(numbers, labels, pos): | ||
plt.bar(pos, numbers, color='blue') | ||
plt.xticks(ticks=pos, labels=labels) | ||
plt.title("Jeopardy Results by Model") | ||
plt.xlabel("Model") | ||
plt.ylabel("Questions Correct") | ||
plt.show() | ||
|
||
def calculatecorrect(): | ||
directory = os.fsencode("./examples/jeopardy/results/") | ||
csv_reader = csv.reader(open("./examples/jeopardy/qasheet.csv", 'rt'), delimiter=',') | ||
for row in csv_reader: | ||
global rows | ||
rows.append(row) | ||
for listing in os.listdir(directory): | ||
filename = os.fsdecode(listing) | ||
if filename.endswith(".txt"): | ||
file = open("./examples/jeopardy/results/" + filename, "rt") | ||
global labels | ||
global numEntries | ||
global numbers | ||
labels.append(filename[:-4]) | ||
numEntries += 1 | ||
i = 1 | ||
totalcorrect = 0 | ||
for line in file.readlines(): | ||
if line.strip() != "------": | ||
print(line) | ||
else: | ||
print("Correct answer: " + rows[i][2] + "\n") | ||
i+=1 | ||
print("Did the AI get the question right? (y/n)") | ||
if input() == "y": | ||
totalcorrect += 1 | ||
numbers.append(totalcorrect) | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
calculatecorrect() | ||
pos = list(range(numEntries)) | ||
labels.append("Human") | ||
numbers.append(48.11) | ||
bar_chart(numbers, labels, pos) | ||
print(labels) | ||
print(numbers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
MODEL=./models/ggml-vicuna-13b-1.1-q4_0.bin | ||
MODEL_NAME=Vicuna | ||
|
||
# exec options | ||
prefix="Human: " # Ex. Vicuna uses "Human: " | ||
opts="--temp 0 -n 80" # additional flags | ||
nl=' | ||
' | ||
introduction="You will be playing a game of Jeopardy. Simply answer the question in the correct format (Ex. What is Paris, or Who is George Washington)." | ||
|
||
# file options | ||
question_file=./examples/jeopardy/questions.txt | ||
touch ./examples/jeopardy/results/$MODEL_NAME.txt | ||
output_file=./examples/jeopardy/results/$MODEL_NAME.txt | ||
|
||
counter=1 | ||
|
||
echo 'Running' | ||
while IFS= read -r question | ||
do | ||
exe_cmd="./main -p "\"$prefix$introduction$nl$prefix$question\"" "$opts" -m ""\"$MODEL\""" >> ""\"$output_file\"" | ||
echo $counter | ||
echo "Current Question: $question" | ||
eval "$exe_cmd" | ||
echo -e "\n------" >> $output_file | ||
counter=$((counter+1)) | ||
done < "$question_file" |
Oops, something went wrong.