superdrew100
commited on
Commit
•
4083497
1
Parent(s):
f144b8c
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,52 @@
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
4 |
+
|
5 |
+
how to use model with gpt4all
|
6 |
+
|
7 |
+
|
8 |
+
import pandas as pd
|
9 |
+
from datasets import load_dataset
|
10 |
+
import re
|
11 |
+
csv_file = "/Users/admin/Downloads/GPT4_output_GPT-2_training_df.csv"
|
12 |
+
# Load the dataset
|
13 |
+
dataset = load_dataset("csv", data_files=csv_file, split="train")
|
14 |
+
|
15 |
+
def stop_on_token_callback(token_id, token_string):
|
16 |
+
# one sentence is enough:
|
17 |
+
if '<eos>' in token_string:
|
18 |
+
return False
|
19 |
+
else:
|
20 |
+
return True
|
21 |
+
|
22 |
+
alpaca_prompt = """Below is an instruction that describes a task, paired with an
|
23 |
+
input that provides further context. Write a response that appropriately completes
|
24 |
+
the request.
|
25 |
+
### Instruction:
|
26 |
+
Find out which character said this specific quote along with their gender
|
27 |
+
### Input:
|
28 |
+
{}
|
29 |
+
### Response:
|
30 |
+
{}"""
|
31 |
+
num_examples=10
|
32 |
+
from gpt4all import GPT4All
|
33 |
+
model = GPT4All('/Users/admin/Downloads/model-unsloth.Q4_K_M.gguf')
|
34 |
+
system_template = '''Below is an instruction that describes a task, paired with an
|
35 |
+
input that provides further context. Write a response that appropriately completes
|
36 |
+
the request.'''
|
37 |
+
# many models use triple hash '###' for keywords, Vicunas are simpler:
|
38 |
+
prompt_template = """### Instruction:
|
39 |
+
Find out which character said this specific quote along with their gender
|
40 |
+
### Input:
|
41 |
+
{0}
|
42 |
+
### Response:
|
43 |
+
"""
|
44 |
+
with model.chat_session(system_template, prompt_template):
|
45 |
+
for i in range(min(num_examples, len(dataset))):
|
46 |
+
row = dataset[i]
|
47 |
+
#response1 = model.generate(row['formatted_input'], callback=stop_on_token_callback)
|
48 |
+
print(i)
|
49 |
+
response1 = model.generate(row['formatted_input'])
|
50 |
+
print(response1)
|
51 |
+
print()
|
52 |
+
print(f"Correct output: {row['TrueSpeaker']}")
|