Settings

Theme

Hacking LangChain for fun and profit

blog.kevinhu.me

79 points by oldgun 2 years ago · 26 comments

Reader

collinc777 2 years ago

There's a pretty steep learning curve to langchain. I recommend avoiding it if you don't need higher level of abstractions.

yujian 2 years ago

Great conceptual explanation of the different primitives in LangChain. Some possible inspiration for your upcoming piece involving vector stores with LangChain - https://milvus.io/blog/conversational-memory-in-langchain.md

fallingmeat 2 years ago

still not sure of the value of the langchain abstraction. does anyone use it in prod?

  • ssivark 2 years ago

    > use it in prod?

    I think that’s the wrong goal.

    Langchain, with its kitchen-sink approach is great for newbies playing around with language models, to get a feel for the different things possible. The uniform interfaces make it very easy to snap together pieces and try things out (iff you don’t care to understand what’s happening under the hood).

    Once you know exactly what you need (which might be 10% of Langchain’s capabilities), it might make sense to avoid all the cruft and build your own simple wrappers suited to the task at hand — especially if you need a robust and transparent/debuggable system. Langchain has a little too much indirection, and clumsy abstractions, to be fit for this purpose.

    • politelemon 2 years ago

      Any examples? How can I see the exact interactions behind the scenes that it's performing in order to DIY? Setting verbose to true doesn't seem to show everything

      • subeadia 2 years ago

        It’s open source mate. Just dig around in the source code for long enough. It’s not pretty, but you can usually figure out how they’re abstracting.

  • J_Shelby_J 2 years ago

    Sort of. I’ve found it’s value , currently, is not in its intended purpose to build “chains” of tools. The moment you have to do something non-standard you have to build from scratch which is more difficult with all of the abstraction involved.

    Where I do find it useful is the many tools it saves me from having to build from scratch. For example I use a page scraper and an embedding service with retries are two things I use it for with the bot I built for my companies slack and discord. In theory I could see using it more in my project eventually. https://github.com/ShelbyJenkins/shelby-as-a-service

  • imrehg 2 years ago

    Yes, the map-reduce chains for summarisation, to work around context size limits of LLM. It works while there is a lot more debugging to do why is it much slower than expected (but it is fortunately fast enough for the task).

    Langchain has a lot of surface area and it is still on 0.0.x, so also much advised to pin the versions hard.

  • wpride 2 years ago

    We do, but mostly as a fairly nice and fairly well-documented interface for plugging together tools like vector DBs and memory with LLMs.

    My feeling is that with the agentic/AutoGPT hype fading and OpenAI adding the functions API there's a lot less value in LangChain's abstractions, at least for production use cases. They're still cool for hacking/toys.

  • viscanti 2 years ago

    Some of the abstractions seem a bit forced, but it seems nice to be abstracted away from how you'd handle vector storage or the LLM that get used (maybe someone launches something that does better than GPT4 on some sets of tasks and a few line change to swap over would be nice).

flakiness 2 years ago

Although LangChain might not be great as a library/framework, it still could be a great starting point to learn about programming pattern for prompt/actor programming.

They used to have a "concepts" page that links to relevant papers but it seems that the page is gone from the doc for some reason :-(

tehsauce 2 years ago

I’ll save yall some time. If you are familiar with concatenating strings in python, langchain is a library which does just that, only a little less cleanly. Hope this helps!

  • dang 2 years ago

    "Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something."

    "Don't be snarky."

    https://news.ycombinator.com/newsguidelines.html

  • loveparade 2 years ago

    That's a bit cynical. It does many other thing as well. For example, it exposes simple re-usable modules, also known as "functions" in Python. Sometimes it also uses Python "lists" by wrapping them into... classes.

    • akiselev 2 years ago

      > Sometimes it also uses Python "lists" by wrapping them into... classes.

      Class incomprehension is the defining feature of LangChain!

  • myth_drannon 2 years ago

    I noticed there is a lot of negativity against langchain on HN. Is it because it's very popular? For example deeplearning.ai has courses on LangChain. You think someone like Andrew Ng will stand behind an overhyped tech?

    • vidarh 2 years ago

      It's worth cribbing ideas from. But most of what it does is simple enough and wrapped in enough abstraction that it's often easier to just take those ideas and apply them to your own code vs. using LangChain itself.

    • bavarianbob 2 years ago

      It inflates its promises and then grossly under delivers.

    • jahewson 2 years ago

      It’s only value is abstractions and it gets these wrong. That said I’m not against it and I hope it improves.

    • objektif 2 years ago

      Absolutely Andrew NG would make questionable decisions imo. I was shocked to see him teach his classes with Matlab year over year when everyone and their mother was proficient in python.

  • intelVISA 2 years ago

    Oh weird, I thought its basic concept was embezzling VC funding?

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection