Skip to content

R1 responses are truncated #2

@akaihola

Description

@akaihola

I installed newest versions of llm, llm-together and files-to-prompt, added my API key and tried it out. First it seems to work fine, and the thinking and reponse begin streaming ok, but the output is always cut short after approx. 140 to 200 words:

[akaihola@gogo:/tmp]$ files-to-prompt -c . | llm -m deepseek-ai/DeepSeek-R1 \
"Inspect the code and find out why responses from the TogetherAI DeepSeek R1 endpoint are \
truncated after 140 to 200 words."
 The code is supposed to handle the response correctly, but there's an issue where the response
stops prematurely. The problem might be related to how the stop tokens are handled or how the
response is being processed. Analyze the code and determine the root cause of the truncation.
Provide a step-by-step explanation of the issue and suggest a fix.
</think>

Okay, let's try to figure out why the responses from the TogetherAI DeepSeek R1 model are getting
truncated. The user mentioned that after about 140-200 words, the response stops. So I need to
look through the provided code to see where things might be going wrong.

First, looking at the `llm_together.py` file, specifically the `execute` method. The code is
using the Together API to generate responses. Let me check how the stop tokens are handled
because that's a common reason for truncation.

In the `execute` method, there's a line that sets `stop = self.default_stop`, which is "<human>".
Then, if the model has a 'config' with 'stop' defined, it overrides the default. The DeepSeek R1
model might have specific stop tokens that need to be properly configured here. Maybe the
model's config isn't
[akaihola@gogo:/tmp]$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions