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

Use Better Models, Better Prompts in Docs #619

Merged
merged 11 commits into from
Feb 7, 2024

Conversation

lapp0
Copy link
Collaborator

@lapp0 lapp0 commented Feb 7, 2024

Some of the results in the docs are difficult to reproduce. Prompt engineering and better model recommendations are applied here to alleviate that.

fixes #586

Notes:

https://github.com/outlines-dev/outlines#multiple-choices

  • update prompt
  • use mistralai/Mistral-7B-Instruct-v0.2

Before (first token probs):

Top Raw Tokens: 'The': 0.560, '\n': 0.212, 'I': 0.106, 'Great': 0.017, 'From': 0.017, 'We': 0.013, 'F': 0.011, 'They': 0.006, EOS: 0.006
Top Guided Tokens: 'P': 0.456, 'N': 0.330, 'Pos': 0.173, 'Ne': 0.018, 'Neg': 0.016, 'Po': 0.007, 'P': 0.000, 'N': 0.000, EOS: -0.000

After (first token probs):

Top Raw Tokens: 'Pos': 0.858, 'POS': 0.060, '\n': 0.031, 'pos': 0.022, '+': 0.007, '**': 0.007, 'The': 0.004, 'Pos': 0.002, EOS: 0.002
Top Guided Tokens: 'Pos': 1.000, 'P': 0.000, 'Po': 0.000, 'Neg': 0.000, 'Ne': 0.000, 'N': 0.000, 'P': 0.000, 'N': 0.000, EOS: -0.000

https://github.com/outlines-dev/outlines?tab=readme-ov-file#type-constraint

  • use `meta-math/MetaMath-Llemma-7B

Now generates 1 + 2 = 3 and sqrt(2) = 1.41421356.

https://github.com/outlines-dev/outlines?tab=readme-ov-file#efficient-json-generation-following-a-pydantic-model

  • use mistralai/Mistral-7B-Instruct-v0.2

Before:

generator("Give me a character description", rng=rng)
Character(name='Anderson', age=28, armor=<Armor.chainmail: 'chainmail'>, weapon=<Weapon.sword: 'sword'>, strength=8)

generator("Give me an interesting character description", rng=rng)
Character(name='B__k_ __lf', age=15, armor=<Armor.plate: 'plate'>, weapon=<Weapon.sword: 'sword'>, strength=55)

name=B__k_ __lf?

After:

generator("Give me a character description", rng=rng)
Character(name='Alex Chen', age=28, armor=<Armor.leather: 'leather'>, weapon=<Weapon.bow: 'bow'>, strength=65)

generator("Give me an interesting character description", rng=rng)
Character(name='Vivian Thr', age=44, armor=<Armor.plate: 'plate'>, weapon=<Weapon.crossbow: 'crossbow'>, strength=125)

https://github.com/outlines-dev/outlines?tab=readme-ov-file#using-context-free-grammars-to-guide-generation

  • changed prompt
  • Use WizardLM/WizardMath-7B-V1.1

Before:

After:

sequence = generator("Alice had 4 apples and Bob ate 2. Write an expression for Alice's apples:")

print(sequence)
# (8-2)

https://github.com/outlines-dev/outlines?tab=readme-ov-file#open-functions

  • Use WizardLM/WizardMath-7B-V1.1
  • Updated prompt, explicitly say object type

Before:

Generates whitespace, never ending

After:

print(add(**result))
# 3

https://github.com/lapp0/outlines/blob/cfg-examples/docs/quickstart.md#regex-guided-generation

  • new prompt
  • use mistralai/Mistral-7B-Instruct-v0.2

Before:

0.0.0.0

After:

result = generator("What is the IP address of localhost?\nIP: ")
print(result)
# 127.0.0.100

https://github.com/lapp0/outlines/blob/cfg-examples/docs/quickstart.md#deploy-using-vllm-and-fastapi

This always results in low quality generations, debugging it can be a separate issue. It hardly ever says just "paris" regardless of the model. Pro

curl http://127.0.0.1:8000/generate \
    -d '{
        "prompt": "<s>Capital of France:</s><s> ",
        "schema": {"type": "string"}

        }'

Changing to

curl http://127.0.0.1:8000/generate \
    -d '{
        "prompt": "Question: What is a language model? Answer:",
        "schema": {"type": "string"}
        }'

@rlouf
Copy link
Member

rlouf commented Feb 7, 2024

Awesome! It looks like you included commits from #616. Can we keep the two PRs separate?

@lapp0
Copy link
Collaborator Author

lapp0 commented Feb 7, 2024

My mistake. Fixed!

@rlouf rlouf merged commit 7fae436 into outlines-dev:main Feb 7, 2024
5 checks passed
@rlouf
Copy link
Member

rlouf commented Feb 7, 2024

Thank you so much, contributions to the documentation are very appreciated!

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