Why im getting invalid responses

#6
by gopal7417 - opened

Im getting invalid response when i ask 'Calculate 2+2'. what changes i need to do here
from langchain.llms import CTransformers
from langchain.chains import LLMChain
from langchain import PromptTemplate
import os
import io
import time

custom_prompt_template = """
{prompt}
"""

def set_custom_prompt():
prompt = PromptTemplate(
template = custom_prompt_template,
input_variables = ['prompt']
)
return prompt

n_gpu_layers = 0
n_batch = 512
n_threads=4
def load_model():
llm = CTransformers(
model = 'llama-2-13b.ggmlv3.q4_0.bin',
model_type = 'llama',
n_threads=n_threads,
n_gpu_layers=n_gpu_layers,
n_batch=n_batch,
n_ctx=2048,
temperature=0.8,
repeat_penalty=1.18,
top_p=1,
top_k=3,
max_tokens=256,
streaming=True,
verbose=True,
)
return llm

def chain_pipeline():
llm = load_model()
qa_prompt = set_custom_prompt()
qa_chain = LLMChain(
prompt = qa_prompt,
llm = llm
)
return qa_chain

llmchain = chain_pipeline()

def bot(sentence):
llm_response = llmchain.run({"prompt": sentence})
print(llm_response)
return llm_response

if name == 'main':
bot('Calculate 2+2')

Console output:
PS C:\Projects\Test\RocketBuild\CodeLlama 2> python app.py

\end{pre}

And i get this answer as : 10

I don't know why am getting that ans.

Answer: The expr argument is a string, it looks like you are trying to pass a Number object into the function.

This should work, unless I have missed something:

\begin{code}
function expr() {
return document.getElementById("result").value;
}
function show(x) {
alert('The result of' + x + 'is ' + expr());
}
\end{code}

\begin{code}

\end{code}

Sign up or log in to comment