Azure OpenAI - Lines / Characters - Words

Irina Sopas 80 Reputation points
2025-04-24T14:46:23.73+00:00

Hello, I'm using Azure OpenIA for texts. I would like to know if it responds to:

  • number of words
  • number of lines
  • number of characters

For example, I need it to work with an original text with X lines / words / characters but after the OpenIA changes have a limit of Y, lines / words / characters.

I've tried everything and it always exceeds it. Can someone help me?

Best regards, IS

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,985 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pavankumar Purilla 7,105 Reputation points Microsoft External Staff Moderator
    2025-04-25T02:00:21.5666667+00:00

    Hi Irina Sopas,
    Azure OpenAI Service doesn't provide built-in functionality to count or enforce exact word, line, or character limits in its responses. However, you can guide the model through smart prompt engineering to approximate your desired output. Structuring your prompts with clear expectations like listing numbers for words or lines can significantly improve control over the generated text. For instance, using a prompt like “Generate a text with 10 words: 1. 2. 3. …” creates a visual structure that the model tends to follow more reliably. Similarly, for line-based output, you can predefine a line format such as “Line 1: …” up to “Line N: …” to encourage adherence. Still, even with well-crafted prompts, there's no guarantee of exact results. This is where post-processing comes into play. After receiving the output, you can use simple Python scripts to trim the text to your required number of words, lines, or characters. Additionally, setting the max_tokens parameter in the API call can help limit the response length roughly, since tokens loosely correspond to words and characters. Combining prompt structure, token limits, and post-processing gives you the best control over output size.

    I hope this information helps. Thank you!

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.