Replies: 3 comments
|
Interesting thought -- any ideas for an API? I could see this maybe being useful for DataType definitions for complex UDFs! |
|
This is a large and complex conversation. More complex than I initially thought it would be when I first started tinkering with the problem back in 2023. So here's what I know:
**This is where the Pydantic support conversation starts to bleed into other feature discussions such as Async UDFs and llm_generate ** This naturally dovetail's nicely with @universalmind303 's llm_generate function which deserves expansion IMO. Bringing the conversation back to vLLM -> the most important reason I think we should focus on vLLM & OpenAI is that as of version 2.44, Ray implements vLLM natively for spinning up an OpenAI API compliant LLMServer, which can be served entirely with LLMConfigs! See the following resources for examples on this: This means we can serve structured generation AT SCALE - which when paired with daft's scalability and I/O performance could provide a new cost performance benchmark with the right models. (Say Phi-4, or Gemma-series). This extends beyond simple chat or text generation inference to transcription and beyond! This is particularly useful to all the Voice AI companies who have achieved strong PMF but completely rely on OpenAI for their inference. Moving to Ray + Daft + vLLM would enable better predictability in costs, service performance, data privacy, and flexibility and could form the foundation of an entire startup! cough cough Now, bringing this back to Pydantic, the whole point of this feature would be to support conversion of Pydantic BaseModels to Daft Schemas. There are a ton of implementation details I've thought about a lot already, but essentially: Naturally, in order to take advantage of Daft's Multimodal datatypes, you may want to use Image/Audio instead of Python Base Types, so the datatype handling needs to be robust. The most important feature here is the composability that dataclass-like schema definition offers. Breaking Data Structures into components enables flexible composition and reuse. My Daft Dataframe simulation engine leverages this to implement the Archetype pattern which enables dynamic creation and streamlined querying of "archetype" tables. Archetypes are defined as the unique exact combinations of components, which are stored in their own tables. But thats another topic I could dive into. Repo: https://github.com/VangelisTech/archetype THE POINT of the components based approach is the Evergreen opportunity of the Single source of truth -> Let your users define their components and they can reuse them as they need. Updating a component triggers Schema Evolution on the table, made possible by modern table formats like Iceberg and Lance. LanceDB's LanceModel attempts to tackle some of this and then some. Beyond it's to_arrow_schema method, LanceModel also enabled users to map source -> vector columns with embedding functions. RAG has kind of fallen off in popularity, but the overall idea here is robust. The exact same mechanism could be used to enable llm_generate to automatically update tables with new data. The last thing I want to touch on is the extension of Pydantic Validation to columnar validation. There is one library that aims to do this called Pandera and they have taken the project pretty far. Pandera is a Dataframe testing tool is fully compliant with Pydantic's API. It leverages hypothesis to enable dataframe level testing and synthetic data generation as well. A Daft integration with Pandera here would go a long way in providing column level validation, but the composition API, in my opinion, could be cleaner. One thing that Pander doesn't offer currently is the ability to convert to Pydantic Models, and by extension, lacks the ability to generate json_schemas necessary for structured generation. From what I've seen in the issues, this shouldn't be too hard to contribute. One key feature that Pandera offers is FastAPI route model validation plus serialization to feather. Other Pydantic to arrow utilities exist like the one @colin-ho used in Sashimi-4-Talent pydantic2arrow or ArrowDantic implemented in Rust. SO! What would the API look like? Well, IMO we would need:
I could go on, but it would probably be worth having Gemini-2.5-Pro compare each of the repos implementations and usage patterns in cursor or something and doing a larger investigation. Potentially just adopting one of the technologies. |
|
In nicer form:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
LanceDB has a utility to convert pydantic objects to arrow schemas ( https://github.com/lancedb/lancedb/blob/main/python/python/lancedb/pydantic.py ), but I haven't seen arrow types implemented in pydantic attributes and fields outside my chats with LLMs.
Given many agentic and gen ai projects leverage pydantic for type validation, how would this best be implemented in Daft?
This speaks to the differences between OO and dataframe based processing, and I was looking for some wise words on the topic.
All reactions