foundation-model-stack / fms-guardrails-orchestrator

🚀 Guardrails orchestration server for application of various detections on text generation input and output.
https://foundation-model-stack.github.io/fms-guardrails-orchestrator/
Apache License 2.0
4 stars 17 forks source link

Warnings and seed fields, not always present in json_response #73

Closed flaviabeo closed 4 months ago

flaviabeo commented 4 months ago

Describe the bug

When running functional tests, calling the /api/v1/task/classification-with-text-generation end point through:

 response = requests.post(url='https://gr2-fmaas-tuning.apps.fmaas-devstage-backend.fmaas.res.ibm.com/api/v1/task/classification-with-text-generation', json=PAYLOAD, headers=HEADERS, verify=SSL)
 json_response = json.loads(response.content.decode(response.encoding))

Platform

Please provide details about the environment you are using, including the following:

Expected behavior

The previous response at v1.0 was:

{
  "generated_text": "I love dogs love@dogs.com",
  "token_classification_results": {
    "input": null,
    "output": []
  },
  "finish_reason": "MAX_TOKENS",
  "generated_token_count": 99,
  "seed": 42,
  "input_token_count": 21,
  "warnings": null,
  "tokens": [
    {
      "text": "\u0120not",
      "logprob": 0.0,
      "rank": 1
    }],
  "input_tokens": []
  }

Containing the seed and warnings fields, even when not populated. Seed needs to be populated when the request goes through the guardrails, and it's expected to have the same value as the text_gen_parameters sent in the request payload.

Observed behavior

The actual response is:

{
  "generated_text": "I hate cats they are stupid. I love dogs love@dogs.com",
  "token_classification_results": {},
  "finish_reason": "EOS_TOKEN",
  "generated_token_count": 59,
  "seed": 0,
  "input_token_count": 21
}

Additional context

When no HAP or PII is found, the warning will be empty, but in the v1.0 the field was returned anyway. So the assertions regarding the fields containing within the response will break. Maybe think if it is mandatory to be at the response?

flaviabeo commented 4 months ago

Can you assign this one to me?

alanbraz commented 4 months ago

seed will be solved by https://github.com/foundation-model-stack/fms-guardrails-orchestrator/issues/74#issuecomment-2166612166 because the bug is that it is calling TGIS with GREEDY.

alanbraz commented 4 months ago

@pmcjr will fix this

pmcjr commented 4 months ago

seed solved by https://github.com/foundation-model-stack/fms-guardrails-orchestrator/issues/74#issuecomment-2166612166 and warnings actually behaving as expected. Closing issue.