Skip to content

Commit

Permalink
feat: add max new tokens parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
umbertogriffo committed Feb 26, 2024
1 parent 66ea81f commit f369537
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion chatbot/chatbot_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def main(parameters) -> None:

client = parameters.client
model = parameters.model
max_new_tokens = parameters.max_new_tokens

init_page(root_folder)
llm = load_llm(client, model, model_folder)
Expand All @@ -102,7 +103,7 @@ def main(parameters) -> None:
with st.chat_message("assistant"):
message_placeholder = st.empty()
full_response = ""
for token in conversational_retrieval.answer(user_input):
for token in conversational_retrieval.answer(question=user_input, max_new_tokens=max_new_tokens):
full_response += llm.parse_token(token)
message_placeholder.markdown(full_response + "▌")
message_placeholder.markdown(full_response)
Expand Down Expand Up @@ -146,6 +147,14 @@ def get_args() -> argparse.Namespace:
default=default_model,
)

parser.add_argument(
"--max-new-tokens",
type=int,
help="The maximum number of tokens to generate in the answer. Defaults to 512.",
required=False,
default=512,
)

return parser.parse_args()


Expand Down

0 comments on commit f369537

Please sign in to comment.