Some quick, high level thoughts on improvements/changes #7662
Replies: 9 comments 9 replies
-
Glad to see an emphasis on documentation, and appreciate everything you and the team have done to make Langchain great! |
Beta Was this translation helpful? Give feedback.
-
Should be separated. In the past, there weren't that many, but now there are so many it makes the documentation harder to read. |
Beta Was this translation helpful? Give feedback.
-
I have already customized prompts for a few chains, but because of the fast pace of development keeping up with changes in components while also having custom components quickly becomes difficult. Wish there was an easy way to separate prompts from code changes in any component. Also, wish there were an easy way to stitch code with LLM chains without having to wrap them in tools. Tools work great when I want the LLM to choose what to do, but there are time when I want a chain to be tied to custom code and that isn't easy enough yet. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the awesome package and glad to provide some feedback.
Conceptual guides, along with examples, can be very helpful for beginners, while a comprehensive reference is a must-have for daily development. This saves you from having to dive into the source code every time, which I kind of appreciated as it taught me a lot.
In my opinion, using class methods is preferable in most cases. It seems a
Above statements gave me an idea. Perhaps it would be beneficial for the core library and case-specific uses if most of the specific chains/agents could be serialized into JSON/YAML files. This would allow users to tune certain keys from outside, such as |
Beta Was this translation helpful? Give feedback.
-
I agree with the comments on modularity and separating the core components. To me one question is what is the lowest level unit (or units) of work? It seems like there are three: (1) prompt (2) LLM call (3) function call. Taking your sql example, theres a prompt, an LLM call to create the query, and a function that uses that query to make a call to the database. If you use these three as interfaces that always accept and return a single pydantic model (or dataclass, or whatever) between them then you should be able to compose any combination of these to create whatever you need. Arguably the LLM call is just a function call, but I think it's sufficiently important to be differentiated. Further, these should be composable in any order, so I could make a function call that passes output to a prompt, the prompt to an LLM, and then to another function that parses the results. You could also break down the composition into Separating this into a core library with a focus on interface stability and modularity would allow for much clearer documentation and allow people to build custom logic without worrying about changes. |
Beta Was this translation helpful? Give feedback.
-
Having to import and construct a wide variety of objects, specific to each use case, feels like having to learn the library's implementation details in order to do basic tasks. The experience would be much better if we could import less stuff and care less about specifics, and instead use more primitives and flat APIs with a quiet confidence that the specific objects are constructed behind the scenes, even "magically". Less Chains, less Memories, less Agents etc. I bet you could run an LLM against the codebase and ask it to group the classes by semantic similarity, and visually see the clusters. These clusters are made of multiple objects, but should probably be exposed to the user by 1-2 objects at most. |
Beta Was this translation helpful? Give feedback.
-
The focus on customizability and the plans for its expansion are much appreciated. The agnostic approach to LLMs is one of the most valuable aspects of LangChain, and I sincerely hope this remains a core part of the philosophy moving forward. There may be criticism from those who find the system overly complex, but the long-term vision is clear: providing a framework that saves developers significant time by enabling hot-swapping of components as needs and technologies evolve. Those who hard-code solutions for specific LLMs may find themselves in difficult situations when they need to switch. OpenAI might be leading now, but the landscape is constantly changing, just look at the Claude 2 release this week! Flexibility is key in this rapidly evolving field. |
Beta Was this translation helpful? Give feedback.
-
I don't know if this is useful in any way, but I wanted to share some ideas and maybe get some feedback on them. I think that a package like LangChain should not focus on particular use-cases, but rather provide building blocks which can be combined/composed in multiple ways to obtain the desired behavior. The particular arrangement of these "building blocks" are called chains and are not included in the package. The users can build the chains themselves by following detailed tutorials. It is easier to illustrate using an example. Below is a mock-up implementation of the
So in this code, LangChain provides only the things that are imported: tools to build prompts, tools to build chains, integrations (db, llm). If the user has a specific use-case in mind, he can follow a tutorial to build the chain where all the building blocks are explained and optimal prompts are provided. This is how this code is supposed to work: first, we define the elements that will go into our chain: sql_cmd_prompt, db, answer_prompt. Then, we compose the elements we defined (and the ones we take from LangChain, like llm, db, logger) into a chain. Then, we run the chain by providing it with an input. The input goes through the chain as follows: The prompt template This is, of course, a mock-up example of how things could work and technical details are irrelevant. Doing things this way keeps LangChain small, highly modular and extensible. The chains themselves are transparent and highly customizable. What do you think? Any form of feedback would be highly appreciated. |
Beta Was this translation helpful? Give feedback.
-
That would be awesome! We can plug in more SQL database backends now to LangChain! |
Beta Was this translation helpful? Give feedback.
-
A lot has changed in the ~8 months since we launched LangChain. We're constantly adapting the library to best help developers build LLM applications. Part of this involves adding new integrations and chains, which is very visible. But another part is making larger changes to base interfaces that require more thought and feedback from the community, and are less visible.
We want to share some of the latter, less visible improvements/changes we're thinking about (and some we're already working on) in order to get feedback and to give everyone a clearer sense of where we see the library going. Note that these are just some higher level thoughts, and we'll follow up with more detailed plans for some of the larger changes shortly.
Documentation
Trying to keep documentation up-to-date in this fast moving field is a constant struggle. In the past month, we've revamped our doc structure, changed the reference guide style, and worked on improving docstrings to some of our more popular chains. However, there is a still a lot of ground to cover, and this is a continual effort. Since we will likely have to prioritize, feedback on which specific chains/components need better documentation is particularly helpful.
We think of documentation in a few buckets, and we’d love feedback on which ones could use the most work!
Modularity
We want to make all parts of LangChain as modular as possible. An obvious example is making the individual modules as standalone as possible. A less obvious example is making subchains more modular.
Let’s consider the [SQLDatabaseChain](https://python.langchain.com/docs/modules/chains/popular/sqlite) as an example. This chain takes user input and constructs a SQL query by calling an LLM, runs that query against a database, then passes those results back to the LLM for summarization. While this is a nice end-to-end flow, we also want to make it as easy as possible to use any individual part of that chain on it's own - e.g., only use the LLMChain that constructs the query. We plan to do this by adding good documentation and constructors for those individual chains. Two ways we are thinking of doing this are adding a
SQLDatabaseChain.create_query_chain
method on the top level chain class, or add acreate_sql_query_chain
function. If you have suggestions or preferences on how we expose this, we’re all ears!Customizability
We want to make it as easy as possible to customize chains. Both the Documentation and Modularity efforts should contribute this. Another big part of this is making it easy to customize prompts for chains. The defaults prompts as meant as general starters, we imagine them being customized for specific use cases, we need to make it easier to do that. We’re also working on things related the [LangChainHub](https://github.com/hwchase17/langchain-hub) to make it easier to discover and share custom prompts.
Base Abstractions
As the stack evolves and best practices for productionizing LLM applications emerge, we’re adapting our interfaces to best support those. We want to put more effort into clarifying these interfaces (documentation) and then also cleaning up any tech debt from previous lives. This is made difficult by the fact that we don’t JUST want to support OpenAI - we want to encourage usage and experimentation of many models. We LOVE feedback and suggestions here on specific ways in which any abstractions seem too restrictive or out of date.
Debugging
When you get an unexpected result, it can often be difficult to debug what exactly went wrong. This is true of complex LLM applications in general. We want to make sure LangChain has best in class debugging abilities. In this vein, we’ve:
langchain.debug = True
option to print out information to the terminalWe are also working on a separate platform offering that will help with this.
Architecture
There is a lot in LangChain. We see several distinct features:
We’ve been trying to add as much as possible so that it’s as easy as possible to get started. But we’re now actively thinking of ways to split these functionalities into multiple packages to keep a each one lighter and more focused. Our current frontrunner proposal is to split things into:
We are debating heavily whether Core and Integrations should be left in the same library for now or separated. This is an area that we’re extremely interested in community feedback - specifically, (1) what parts of LangChain you’d like to be separate so you can use them in a standalone manner, (2) how you’d like new use-case specific chains/agents to be added.
We are actively thinking about this and listening to feedback, and will share more concrete thoughts and plans here next week.
Beta Was this translation helpful? Give feedback.
All reactions