Loading

Quipoin Menu

Learn • Practice • Grow

/
interview

Q1. How do you specify length constraints in a prompt?
Be explicit about the desired length using numbers and units.
Examples:
• "Answer in exactly two sentences."
• "Write a summary of no more than 50 words."
• "Provide 3 bullet points, each under 10 words."
• "Generate a 100‑character tweet (including spaces)."
• "List 5 items, each on a new line."

Avoid vague terms like "short" or "brief" – models interpret them inconsistently.
For better results, you can ask the model to first count tokens or characters, but this isn't always accurate.
Iterative testing helps find the right phrasing.

Q2. What are common format constraints you can enforce?
Common format constraints include:
• Bullet points vs. numbered lists vs. paragraphs
• JSON, XML, YAML, CSV, or Markdown
• Tables with specific columns
• Code blocks with language tags
• Separators like dashes or blank lines
• Capitalization rules (e.g., all lowercase, sentence case)
• No markdown or no emojis

Example: "Output the result as a JSON object with keys 'name', 'age', and 'city'. Do not include any other text."
Enforcing formats is critical for downstream processing.

Q3. How can you make the model follow a strict output format like JSON?
To enforce JSON output:
1. Explicitly state the schema: "Output a JSON object with fields: "name" (string), "score" (number)."
2. Provide a one‑shot example (recommended):
Example: {"name": "John, "score": 85}
Now process: ...

3. Use system prompts (for chat models) to set the format globally.
4. In some APIs, you can set response format to JSON.
5. After generation, programmatically validate and repair if needed (e.g., extract JSON from text).

Few‑shot is the most reliable method for custom schemas.

Q4. Why might a model ignore length or format constraints?
Reasons for ignoring constraints:
• The constraint is placed in the middle of the prompt (lost in the middle).
• The model's training data rarely contained such precise constraints (older models struggle more).
• The task itself requires more tokens than allowed (e.g., summarizing a long article in 10 words is impossible).
• Contradictory instructions (e.g., "Be detailed" and "Use 5 words").
• The model's generation is cut off by a max token limit before fulfilling the constraint.

Solution: place constraints at the end of the prompt, use stronger language, and reduce task complexity.

Q5. Give an example prompt that combines length, format, and tone constraints.
Example prompt:
"You are a social media manager for a coffee shop.
Write a friendly tweet (maximum 240 characters) announcing a new caramel latte.
Use an emoji ☕ and include the hashtag #NewBrew.
Do not use all caps. Output only the tweet text, no extra commentary."

This prompt specifies:
• Role (social media manager)
• Tone (friendly)
• Length (240 chars)
• Format (tweet only, no extra text)
• Elements (emoji, hashtag)
• Constraint (no all caps)

Such a comprehensive prompt yields a ready‑to‑use social media post.