Suggested architecture for Kedro & LLMs #3979
Replies: 3 comments 9 replies
-
Hi @astrojuanlu, Coming from our PR to share my thoughts on how kedro should work with LLMs. My usual workflow is LLM is like this: I need a open source model so that requires defining some params for huggingface model. With LLMs in mind, there is lots of configs around managing models which I believe are suited to kedro catalog but I don't personally like considering them as datasets. So some separation like For huggingface I can imagine wrappers around getting model and tokenizer or pipeline depending on the use case is a good start. Also ability to save to local disk and/or to huggingface. This could be a dataset or a model as well. For instance, creating embeddings from a dataset and I would like to save them to huggingface. Adding more vector store capabilities would be nice abstraction like both open source tools as well as some apis. (qdrant etc) Now for the API endpoint, there were some nice packages ( i forgot the name) which makes a unified entrypoint for the all other different apis like OpenAI, Claude etc. This would def help however a this makes a call to an endpoint so here, useful features such as adding pricing or logging. Ability to test this with a smaller local model would be super nice (not sure how for now). Lastly, there is some work around prompts. Managing prompts, strings etc. Maybe there is something to do there. Overall since kedro aims to manage data IO, simplifying getting the open source models (even lazy loading big models), making it seamless to work with APIs is a step in the right direction imo. Let me know if there are some points that weren't clear. Happy to explain it in detail. |
Beta Was this translation helpful? Give feedback.
-
Kedro design decisionsKedro was built against scar tissue gained building 'traditional' ML models, let's say One of the tensions in supporting advanced user of Kedro has been the balance between supporting dynamic pipelines. With dynamism one quickly gets questions about conditional logic and our party line has always been some version of -
Kedro 🤝 LLM scepticismOrchestrators have work at a higher level of abstraction than Kedro. This is to say where 1 node is often 1 K8s pod, and have opted to introduce this type of operator where the DAG complexity introduced is lower. Examples (1), (2), (3). Personally I currently do not believe our current principles or design decisions around Kedro lend themselves well to the requirements of working with LLMs. Whether we change / relax these is another question.... If you look at the effort that's gone into Prefect Control Flow there is a great deal of work that's gone into handling IO of various function calls within the task DAG. This pattern is very different to Kedro's decoupled dataset centric way of doing IO outside of nodes. Proposition: Let's make Kedro a great fit for deterministic 'function calling'Our biggest most important issue stems back to #143 and the fact that the Kedro session isn't fit for injecting data at runtime #2169. I believe Kedro could be a great ergonomic solution for LLM systems to perform complex, custom "Function calls" as part of their wider task chains/graphs. If we solve these underlying issues... we'll solve a bunch of problems in #3094 and this LLM space. |
Beta Was this translation helpful? Give feedback.
-
I see the value in providing a way to use LLMs with Kedro. As a minimum requirement, I would consider providing the mechanism to configure the model, switch between the LLMs, manage prompts, generate output, and get embeddings.
Here, the question is if "low-lever" users, let's say those who implement models/serve them in production, are going to use Kedro for that. IMO, we can start from the most obvious cases when people just create their pipelines using ready-to-use LLMs/ external APIs and need some mechanism to incorporate them and configure them, as this covers most of the cases. I would also not avoid using When we worked with the We also came to dynamic model initialisation, in our case it can help users to switch between different models without need to add extra datasets (OpenAI, Cohere, Azure, etc). If combine those ideas the
As for dynamic promts - it can be partly solved via placeholders in the prompts that are filled at the runtime as it's done in
I think there's a difference between adding some feature to the framework, which leads to non-reproducible behaviour, and using Kedro with non-deterministic models (via dataset). We cannot control the last as users can make it anyway but should we? |
Beta Was this translation helpful? Give feedback.
-
I've been toying with GenAI & Kedro for a while, first with Hugging Face (thanks to our datasets) and now through Ollama, which gives an OpenAI-compatible HTTP API:
I'm trying to wrap my head around what would be the "blessed" way to implement this in Kedro.
1. Frozen inputs
One way would be to let the dataset include the prompt as part of the configuration, as follows:
so
catalog.load("llama3_ds")
gives immediately an output.Pro: The Kedro dataset performs all of the I/O needed. It's probably the "most pure" implementation. Could be modeled by using the already existing
APIDataset
.Con: What if my prompt is not known at definition time?
2. Wrapper object
Another way of doing it would be returning a wrapper object to the node:
Which would then allow me to do things like
Pro: It allows dynamic prompts, which might be necessary for some use cases.
Con 1: The node is performing I/O, which means that we're "breaking" the Kedro notion of what the node and the dataset should do.
Con 2: It breaks reproducibility, given that the prompt is not static (in this case it was a
param
, but could as well be the output of another node)At the same time, we're already "breaking" that I/O separation in several places:
PartitionedDataset
https://docs.kedro.org/en/stable/data/partitioned_and_incremental_datasets.html#partitioned-dataset-loadAny thoughts?
Beta Was this translation helpful? Give feedback.
All reactions