How do i make the model use information that has been previously entered? #391
Unanswered
bennybweng
asked this question in
Q&A
Replies: 2 comments
|
In python you can manually feed the output back as input. You will need to feed both the LLM output and your new inputs back as a prompt. Please be aware that you will run out of the tiny 2048 token context pretty quickly. |
0 replies
|
i used something similar to this for my project: def chat(message):
global chat_memory
USER_NAME = "Human"
AI_NAME = "llama-cpp-python"
out = model.create_completion(prompt=f"""
[put your prompt here]
---An example conversation---
[PUT YOUR EXAMPLE HERE]
--- end of example conversation----
here is your current chat history, use this to remember context from earlier. (if {AI_NAME} said this, you said this. Otherwise, that was a user.).
this is for you to refrence as memory, not to use in chat. i.e. "oh yes, i remember you saying this some time ago." if it isn't acutally in history, dont say it.
---beginning of your chat history, use this as memory.---
{chat_memory}
---end of your chat history---
--- current chat session, use this in your response ---
{USER_NAME}, message:{message}
{AI_NAME}:""",temperature=0.7,repeat_penalty=1.1,max_tokens=512,stop=[f"message:",f"{USER_NAME}:",f"{AI_NAME}:"],top_p=0.95,top_k=20)
dat = json.dumps(out)
final = json.loads(dat)
list = final.get("choices")
nxt = next(iter(list), 'fail')
txt = nxt.get("text")
chat_memory += f"{AI_NAME}, message: {txt} \n"
return txtwhat this method does is:
do note you almost certainly want to set |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
See this example code:
I would expect the second output to be something like: "My favorite food is bread" but instead it returns: "My favorite food is pizza."
How do i make the model remember information? Do i need to use the low-level-API?
If my question is a little unclear, i am looking for something interactive like in the main.cpp from llama.cpp but instead of entering the prompts in the terminal, i want to enter them through the python code. Sorry if the answer is obvious, I'm pretty new to this stuff.
All reactions