Skip to content

v0.0.27

Compare
Choose a tag to compare
@parkervg parkervg released this 16 Oct 00:16
· 103 commits to main since this release

Few-Shot Prompting + Retrieval for Ingredients

This release includes many new updates, most notably an interface allowing you to define custom few-shot examples for ingredient functions and dynamically retrieve the most relevant examples at runtime via a haystack-based retriever.

For example:

from blendsql import blend, LLMQA
from blendsql.ingredients.builtin import DEFAULT_QA_FEW_SHOT

ingredients = {
    LLMQA.from_args(
        few_shot_examples=[
            *DEFAULT_QA_FEW_SHOT,
            {
                "question": "Which weighs the most?",
                "context": {
                    {
                        "Animal": ["Dog", "Gorilla", "Hamster"],
                        "Weight": ["20 pounds", "350 lbs", "100 grams"]
                    }
                },
                "answer": "Gorilla",
                # Below are optional
                "options": ["Dog", "Gorilla", "Hamster"]
            }
        ],
        # Will fetch `k` most relevant few-shot examples using embedding-based retriever
        k=2,
        # Lambda to turn the pd.DataFrame to a serialized string
        context_formatter=lambda df: df.to_markdown(
            index=False
        )
    )
}
smoothie = blend(
    query=blendsql,
    db=db,
    ingredients=ingredients,
    default_model=model,
)

See this section in the README for more information.

Full Changelog: v0.0.26...v0.0.27