We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This function pushes "weights" (prompts) to be "small" (short).
class TokenCountLoss(Module): def __init__(self, max_tokens): super().__init__() self.call_fn = StringBasedFunction( fn=partial(self._eval_df, max_tokens=max_tokens), function_purpose="evaluating the token count of the model's response", ) @classmethod def _eval_df(cls, input_val: tg.Variable, max_tokens: int) -> str: tc = get_token_count(input_val.value) out = f"token count: {tc}; " if tc > max_tokens: return out + f"exceeded max tokens by {tc - max_tokens}" return out + "within limits" def forward(self, **kwargs): return self.call_fn(inputs=kwargs) ... reg_loss = TokenCountLoss(max_tokens)(input_val=model.system_prompt) losses.append(reg_loss) total_loss = tg.sum(losses)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This function pushes "weights" (prompts) to be "small" (short).
The text was updated successfully, but these errors were encountered: