Replies: 2 comments
-
🤖 Hello, Based on your description, it seems like you want to stop the generation of text once the final category in German is produced. To achieve this, you can use the You can set the Here is an example of how you can modify the def _create_message_dicts(
self, messages: List[BaseMessage], stop: Optional[List[str]]
) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]:
params = self._client_params
if stop is not None:
if "stop" in params:
raise ValueError("`stop` found in both the input and default params.")
params["stop"] = stop
message_dicts = [convert_message_to_dict(m) for m in messages]
return message_dicts, params In the above code, you can set the stop_tokens = ["<end_of_category_in_German>"]
response = model(prompt, n_predict=55, stop=stop_tokens) Please replace You can find more details about this in the libs/langchain/langchain/llms/gpt4all.py and libs/langchain/langchain/chat_models/openai.py files. I hope this helps! If you have any other questions, feel free to ask. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Are you using the ChatCompletion API (i.e. your model is of type |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm using AzureOpenAI with gpt 3.5 Turbo and simply want to receive a product categorization for a given product description.
Unfortunately the output I receive always contains some kind of examples for other (fictional) product descriptions.
Here is an example:
Prompt:
Chat output:
The fuction to generate the output is the following:
Does anybody know how to cope with this issue? (besides parsing the result from the long output, as this will produce unnecessary tokens -> costs)
Beta Was this translation helpful? Give feedback.
All reactions