Skip to content
New issue

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

The json schema example doesn't work correctly #1271

Open
lhgravendeel opened this issue Nov 18, 2024 · 0 comments
Open

The json schema example doesn't work correctly #1271

lhgravendeel opened this issue Nov 18, 2024 · 0 comments
Labels

Comments

@lhgravendeel
Copy link

lhgravendeel commented Nov 18, 2024

Describe the issue as clearly as possible:

Using the dockerized example from https://dottxt-ai.github.io/outlines/latest/reference/serve/vllm/e:

Started container with:

docker run --gpus all -p 8000:8000 outlinesdev/outlines --model="microsoft/Phi-3-mini-4k-instruct"

Running the example prompt of:

curl http://127.0.0.1:8000/generate \
    -d '{
        "prompt": "What is the capital of France?",
        "schema": {"type": "string", "maxLength": 5}
        }'

The response that comes back is:

{"text":["What is the capital of France?\", \""]}

I also tried updating the schema to be a full object:

curl http://127.0.0.1:8000/generate -d '{"prompt": "What is the capital of France?","schema": {"type": "object", "properties":{"capital": {"type":"string", "description": "The capital that was requested"}}}}'

This returns the expected answer, in an expected JSON structure - except the JSON is stringified inside an object with an array of text elements. This is the output data:

{"text":["What is the capital of France?{ \"capital\": \"Paris\" }"]}

Steps/code to reproduce the bug:

Started container with:

docker run --gpus all -p 8000:8000 outlinesdev/outlines --model="microsoft/Phi-3-mini-4k-instruct"

Running the example prompt of:

curl http://127.0.0.1:8000/generate \
    -d '{
        "prompt": "What is the capital of France?",
        "schema": {"type": "string", "maxLength": 5}
        }'

Result:

{"text":["What is the capital of France?\", \""]}

Alternatively, reproduce it with a JSON object:

curl http://127.0.0.1:8000/generate -d '{"prompt": "What is the capital of France?","schema": {"type": "object", "properties":{"capital": {"type":"string", "description": "The capital that was requested"}}}}'

This returns:

{"text":["What is the capital of France?{ \"capital\": \"Paris\" }"]}

Expected result:

Expected to see `Paris` or in the second example:

{"capital": "Paris"}

Error message:

No response

Outlines/Python version information:

Version information

Docker image outlinesdev/outlines:latest sha256:523381fa1d10b1a9b5124b241952140712af2105fcf841473ff7e1a3a125bad7
Maps to version 0.1.3

ENV PYTHON_VERSION=3.10.15

Startup log: Initializing an LLM engine (v0.5.1)

Tried this both on Windows 11 with WSL 2 and Docker Desktop, and a clean Debian 12 VM

Context for the issue:

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant