https://www.boundaryml.com logo
Hello, does a model need to honor json
# suggestions
a
Copy code
class GSM8KResponse {
  chain_of_thought string @description(#"
    Keep reasoning concise (2-5 sentences). Avoid filler.
  "#)
  final_answer string @description(#"
    Return as '#### <number>' (e.g., '#### 42' or '#### -3.5').
    Do not include units or extra words.
  "#)
  confidence_score float @description("Self-evaluated confidence between 0.0 and 1.0.")
}

function SolveGSM8K(question: string) -> GSM8KResponse {
  client TogetherQwen7BLowTemp

  prompt #"
    You solve grade-school math word problems.

    Problem:
    {{ question }}

    {{ ctx.output_format }}
  "#
}

test TestSolveGSM8K {
  functions [SolveGSM8K]
  args {
    question "If a store sells 12 apples and then sells 8 more, how many apples were sold in total?"
  }
}

client<llm> TogetherQwen7BLowTemp {
  provider "openai-generic"
  retry_policy Exponential
  options {
    base_url "https://api.together.ai/v1"
    model "Qwen/Qwen2.5-7B-Instruct-Turbo"
    api_key env.TOGETHER_API_KEY
    temperature 0.3
    logprobs true
    top_logprobs 1
  }
}
here is the raw llm response: chain_of_thought: The store initially sold 12 apples and then sold 8 more. To find the total, add 12 and 8. final_answer: #### 20 confidence_score: 1.0
BAML is unable to parse the response
interstingly, once i concatenate the descriptions in one line the model seems to honor the json output format:
Copy code
class GSM8KResponse {
  chain_of_thought string @description("The step-by-step reasoning process to solve the problem.")
  final_answer string @description(" Return as '#### <number>' (e.g., '#### 42' or '#### -3.5'). Do not include units or extra words.")
  confidence_score float @description("Self-evaluated confidence between 0.0 and 1.0.")
}