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

[Feature Request] Data Extraction #3

Open
efremidze opened this issue Aug 2, 2023 · 4 comments
Open

[Feature Request] Data Extraction #3

efremidze opened this issue Aug 2, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@efremidze
Copy link

efremidze commented Aug 2, 2023

I would like to request the addition of support for Data Extraction using Langchain like kor. This would help users extract structured data from text.

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']
{'player': {'artist': ['paul simon', 'led zeppelin', 'the doors']}}
@buhe
Copy link
Owner

buhe commented Aug 2, 2023

Thanks, I'll take a look.

@buhe
Copy link
Owner

buhe commented Aug 2, 2023

On iOS, how scenes or apps use it, thank you.

@efremidze
Copy link
Author

App makes a request to extract data from text. It would be zero shot.

@buhe
Copy link
Owner

buhe commented Aug 2, 2023

Can you help contribute to this requirement? If there is anything I need to change, please feel free to let me know.

@buhe buhe added the enhancement New feature or request label Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants