How do I export the full response from gpt4all into a single string? And how do I suppress the model parameters (gptj_generate... and gptj_model_load...) from being printed?
Example:
response="German beer is a very popular beverage all over the world. The brewing process and the ingredients used are very well studied and have been proven to be very effective in keeping the body healthy. German beer is also very popular because it is brewed with only water and malted barley, which are very natural ingredients, thus maintaining a healthy lifestyle."
code:
#https://github.com/nomic-ai/pygpt4all
from pygpt4all.models.gpt4all_j import GPT4All_J
def new_text_callback(text):
print(text, end="")
model = GPT4All_J('./models/ggml-gpt4all-j-v1.3-groovy.bin')
model.generate("What do you think about German beer?",new_text_callback=new_text_callback)
response:
What do you think about German beer?
German beer is a very popular beverage all over the world. The brewing process and the ingredients used are very well studied and have been proven to be very effective in keeping the body healthy. German beer is also very popular because it is brewed with only water and malted barley, which are very natural ingredients, thus maintaining a healthy lifestyle.<|endoftext|>
gptj_generate: mem per token = 15478000 bytes
gptj_generate: load time = 0.00 ms
gptj_generate: sample time = 0.47 ms
gptj_generate: predict time = 9726.31 ms / 1215.79 ms per token
gptj_generate: total time = 14902.11 ms
gptj_model_load: loading model from './models/ggml-gpt4all-j-v1.3-groovy.bin' - please wait ...
gptj_model_load: n_vocab = 50400
gptj_model_load: n_ctx = 2048
gptj_model_load: n_embd = 4096
gptj_model_load: n_head = 16
gptj_model_load: n_layer = 28
gptj_model_load: n_rot = 64
gptj_model_load: f16 = 2
gptj_model_load: ggml ctx size = 4505.45 MB
gptj_model_load: memory_size = 896.00 MB, n_mem = 57344
gptj_model_load: ................................... done
gptj_model_load: model size = 3609.38 MB / num tensors = 285
gptj_generate: seed = 1683099839
gptj_generate: number of tokens in prompt = 8
I realised that this is the way to get the response into a string/variable. Straightforward!
response=model.generate("What do you think about German beer?",new_text_callback=new_text_callback)