We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi all,
Thanks for the great library. I'm trying to categorize publications into ML/Astro/Physics. Just curious what the right way to do this is.
I am using the following schema:
import outlines from pydantic import BaseModel, field_validator from enum import Enum class Category(str, Enum): ML = "ML" Astro = "Astro" Physics = "Physics" class PublicationCategories(BaseModel): categories: set[Category] @field_validator('categories') @classmethod def ensure_foobar(cls, v): if len(v) == 0: raise ValueError('No categories found') return v model = outlines.models.transformers( "HuggingFaceTB/SmolLM-135M-Instruct", device="auto", ) category_extractor = outlines.generate.json(model, PublicationCategories)
The validator hits this error when the LLM tries to return no outputs:
Value error, No categories found [type=value_error, input_value=[], input_type=list] For further information visit https://errors.pydantic.dev/2.10/v/value_error
So I'm just wondering the proper way to do this. Thanks!
So I am just wondering how I can specify a field that is a set with a minimum of 1 element?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi all,
Thanks for the great library. I'm trying to categorize publications into ML/Astro/Physics. Just curious what the right way to do this is.
I am using the following schema:
The validator hits this error when the LLM tries to return no outputs:
So I'm just wondering the proper way to do this. Thanks!
So I am just wondering how I can specify a field that is a set with a minimum of 1 element?
The text was updated successfully, but these errors were encountered: