huggingface / text-generation-inference

Large Language Model Text Generation Inference
http://hf.co/docs/text-generation-inference
Apache License 2.0
9.01k stars 1.06k forks source link

generate() got multiple keyword arguments for 'stop_sequences' #669

Closed adarshxs closed 1 year ago

adarshxs commented 1 year ago

System Info

Im not sure what exactly is causing the issue. Is it langchain, TGI, or streamlit

TypeError: generate() got multiple values for keyword argument 'stop_sequences' Traceback: File "/usr/local/lib/python3.8/dist-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script exec(code, module.dict) File "/workspace/app.py", line 154, in main() File "/workspace/app.py", line 109, in main handle_userinput(user_question) File "/workspace/app.py", line 79, in handle_userinput response = st.session_state.conversation({'question': user_question}) File "/usr/local/lib/python3.8/dist-packages/langchain/chains/base.py", line 243, in call raise e File "/usr/local/lib/python3.8/dist-packages/langchain/chains/base.py", line 237, in call self._call(inputs, run_manager=run_manager) File "/usr/local/lib/python3.8/dist-packages/langchain/chains/conversational_retrieval/base.py", line 142, in _call answer = self.combine_docs_chain.run( File "/usr/local/lib/python3.8/dist-packages/langchain/chains/base.py", line 445, in run return self(kwargs, callbacks=callbacks, tags=tags, metadata=metadata)[ File "/usr/local/lib/python3.8/dist-packages/langchain/chains/base.py", line 243, in call raise e File "/usr/local/lib/python3.8/dist-packages/langchain/chains/base.py", line 237, in call self._call(inputs, run_manager=run_manager) File "/usr/local/lib/python3.8/dist-packages/langchain/chains/combine_documents/base.py", line 106, in _call output, extra_return_dict = self.combine_docs( File "/usr/local/lib/python3.8/dist-packages/langchain/chains/combine_documents/stuff.py", line 165, in combine_docs return self.llm_chain.predict(callbacks=callbacks, inputs), {} File "/usr/local/lib/python3.8/dist-packages/langchain/chains/llm.py", line 252, in predict return self(kwargs, callbacks=callbacks)[self.output_key] File "/usr/local/lib/python3.8/dist-packages/langchain/chains/base.py", line 243, in call raise e File "/usr/local/lib/python3.8/dist-packages/langchain/chains/base.py", line 237, in call self._call(inputs, run_manager=run_manager) File "/usr/local/lib/python3.8/dist-packages/langchain/chains/llm.py", line 92, in _call response = self.generate([inputs], run_manager=run_manager) File "/usr/local/lib/python3.8/dist-packages/langchain/chains/llm.py", line 102, in generate return self.llm.generate_prompt( File "/usr/local/lib/python3.8/dist-packages/langchain/llms/base.py", line 188, in generate_prompt return self.generate(prompt_strings, stop=stop, callbacks=callbacks, kwargs) File "/workspace/app.py", line 18, in generate super().generate(*args, kwargs) File "/usr/local/lib/python3.8/dist-packages/langchain/llms/base.py", line 281, in generate output = self._generate_helper( File "/usr/local/lib/python3.8/dist-packages/langchain/llms/base.py", line 225, in _generate_helper raise e File "/usr/local/lib/python3.8/dist-packages/langchain/llms/base.py", line 212, in _generate_helper self._generate( File "/usr/local/lib/python3.8/dist-packages/langchain/llms/base.py", line 604, in _generate self._call(prompt, stop=stop, run_manager=run_manager, kwargs) File "/usr/local/lib/python3.8/dist-packages/langchain/llms/huggingface_text_gen_inference.py", line 156, in _call res = self.client.generate(

Information

Tasks

Reproduction

generate() got multiple keyword arguments for 'stop_sequences' upon running the script along with streamlit

Expected behavior

from langchain.llms.huggingface_text_gen_inference import HuggingFaceTextGenInference
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

llm = HuggingFaceTextGenInference(
    inference_server_url='http://127.0.0.1:8080',
    max_new_tokens=512,
    top_k=10,
    top_p=0.95,
    typical_p=0.95,
    temperature=0.85,
    stop_sequences=['</s>'],
    repetition_penalty=1.03,
    stream=True
)
print(llm("What is a proctor?", callbacks=[StreamingStdOutCallbackHandler()]))

the above script works properly but while using it with chainlit I run into the generate() got multiple keyword arguments for 'stop_sequences'

Narsil commented 1 year ago

As you can see in your stacktrace, the issue is in LangChain.

Will close this, feel free to comment if you feel this is not correct.

adarshxs commented 1 year ago

yes got it thanks!