eyurtsev / kor

LLM(😽)
https://eyurtsev.github.io/kor/
MIT License
1.6k stars 88 forks source link

WARNING! msgs when running kor style schema #204

Closed natea closed 1 year ago

natea commented 1 year ago

When I try to run the first example (using kor style schema), I get the following errors:

WARNING! frequency_penalty is not default parameter.
                    frequency_penalty was transferred to model_kwargs.
                    Please confirm that frequency_penalty is what you intended.
WARNING! presence_penalty is not default parameter.
                    presence_penalty was transferred to model_kwargs.
                    Please confirm that presence_penalty is what you intended.
WARNING! top_p is not default parameter.
                    top_p was transferred to model_kwargs.
                    Please confirm that top_p is what you intended.

Is there a getting started guide with a complete working example?

eyurtsev commented 1 year ago

Hi @natea, you can remove those parameters from the initialization of the code -- I'll update the docs at some point to remove them, but should be safe to continue.

For the future, when reporting issues it's useful to include a code snippet and a full stack trace.

natea commented 1 year ago

@eyurtsev here is the exact code that I used:

from langchain.chat_models import ChatOpenAI
from kor import create_extraction_chain, Object, Text 

llm = ChatOpenAI(
    model_name="gpt-3.5-turbo",
    temperature=0,
    max_tokens=2000,
    frequency_penalty=0,
    presence_penalty=0,
    top_p=1.0,
)

schema = Object(
    id="player",
    description=(
        "User is controlling a music player to select songs, pause or start them or play"
        " music by a particular artist."
    ),
    attributes=[
        Text(
            id="song",
            description="User wants to play this song",
            examples=[],
            many=True,
        ),
        Text(
            id="album",
            description="User wants to play this album",
            examples=[],
            many=True,
        ),
        Text(
            id="artist",
            description="Music by the given artist",
            examples=[("Songs by paul simon", "paul simon")],
            many=True,
        ),
        Text(
            id="action",
            description="Action to take one of: `play`, `stop`, `next`, `previous`.",
            examples=[
                ("Please stop the music", "stop"),
                ("play something", "play"),
                ("play a song", "play"),
                ("next song", "next"),
            ],
        ),
    ],
    many=False,
)

chain = create_extraction_chain(llm, schema, encoder_or_encoder_class='json')
chain.run("play songs by paul simon and led zeppelin and the doors")['data']
eyurtsev commented 1 year ago

Can do this

llm = ChatOpenAI(
    model_name="gpt-3.5-turbo",
    temperature=0,
    max_tokens=2000,
)
natea commented 1 year ago

Thanks, I don't get any errors when I use that, but I'm looking for a getting started guide for how to actually use kor. How do I interact with it, or get it to generate results?

eyurtsev commented 1 year ago

The guide is here: https://eyurtsev.github.io/kor/tutorial.html

What are you using kor for extraction or generation?

eyurtsev commented 1 year ago

Updated docs, so issue with warnings should be resolved.