-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathTEST.py
40 lines (33 loc) · 1.14 KB
/
TEST.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from neuralgpt import NeuralGPT
from DualCoreLLM import DualCoreLLM # if needed
import re
# Load pretrained model
model = NeuralGPT.load_model('model.bin') # provide path to model file
# Define list of prompts
prompts = ['identify yourself', 'How can I improve my life?']
# Define function for preprocessing user input
def preprocess_input(text):
text = text.lower()
text = re.sub(r'[^\w\s]', '', text) # remove special characters
return text
# Define function for generating responses
def generate_response(prompt):
response = model.generate(prompt)
# Evaluate coherence of response
# ...
return response
# Define function for testing coherence of responses
def test_coherence(prompt):
input_text = input(prompt + ': ')
preprocessed_text = preprocess_input(input_text)
response = generate_response(preprocessed_text)
# Evaluate coherence of response
# ...
return coherence_score
# Run test for each prompt
total_score = 0
for prompt in prompts:
score = test_coherence(prompt)
total_score += score
# Output final score
print('Coherence score:', total_score)