[HN Gopher] The Problem with LangChain
___________________________________________________________________
The Problem with LangChain
Author : minimaxir
Score : 109 points
Date : 2023-07-14 16:11 UTC (6 hours ago)
(HTM) web link (minimaxir.com)
(TXT) w3m dump (minimaxir.com)
| mp3il wrote:
| Had the same frustrating experience. The system prompt being
| ignored when running an agent etc.
|
| But as always I trust the OSS community to make it better or
| replace it with something else
| moonchrome wrote:
| I'm in the exact same spot as the author just a few days in
| instead of months.
|
| Frankly I could see langchain is garbage software just by looking
| at the code.
|
| It still helps me get shit done fast to figure out how things are
| supposed to work. Sort of a cookbook of AI recepies. Once I have
| an approach narrowed down I'll rewrite everything on top of stuff
| langchain is supposedly wrapping. For now it's faster than
| tracking down individual libraries and learning the apis. It will
| stay in notebooks basically.
| saulpw wrote:
| Yes! This is why I started working on AIPL. The scripts are
| much more like recipes (linear, contained in a single-file,
| self-evident even to people who don't know the language). For
| instance, here's a multi-level summarizer of a webpage:
| https://github.com/saulpw/aipl/blob/develop/examples/summari...
|
| The goal is to capture all that knowledge that langchain has,
| into consistent legos that you can combine and parameterize
| with the prompts, without all the complexity and boilerplate of
| langchain, nor having to learn all the Python libraries and
| their APIs. Perfect for prototypes and experiments (like a
| notebook, as you suggest), and then if you find something that
| really works, you can hand-off a single text file to an
| engineer and they can make it work in a production environment.
| ColinEberhardt wrote:
| Thanks for referencing the 'implementing LangChain in 100 lines
| of code' post I wrote a few months back. Really glad it was
| useful. And yes, I completely agree, much of LangChain is an
| abstraction that does little more than obfuscate.
| dmezzetti wrote:
| If you'd like another LLM framework option that also is a vector
| database, check out txtai (https://github.com/neuml/txtai).
|
| Disclaimer: I am the author of txtai
| Der_Einzige wrote:
| Big +1 to this, txtai is an excellent library and is a breath
| of fresh air to use. In particular, the way that graphs are
| integrated with LLMs and with SQL or related databases is
| excellent!
| dpeterson wrote:
| In response to how over complex I saw the langchain and autogpt
| code was, I made my own implementation that starts with a solid
| foundation to doing similar types of things
| https://youtu.be/KN_etwBLej8 and I share the code if you want to
| do the same
| simonw wrote:
| I added a Python library API to my LLM CLI tool recently which
| offers a very lightweight way to call models:
| https://llm.datasette.io/en/stable/python-api.html
| import llm model = llm.get_model("gpt-3.5-turbo")
| model.key = 'YOUR_API_KEY_HERE' response = model.prompt(
| "Five surprising names for a pet pelican" )
| print(response.text())
|
| Or you can stream the responses like this:
| response = model.prompt( "Five diabolical names for a
| pet goat" ) for chunk in response:
| print(chunk, end="")
|
| It works with other models too, installed via plugins - including
| models that can run directly on your machine:
| pip install llm-gpt4all
|
| Then: model = llm.get_model("ggml-vicuna-7b-1")
| print(model.prompt( "What is the capital of France?"
| ).text())
|
| It also handles conversations, where each prompt needs to include
| the previous context of the conversation: c =
| model.conversation() print(c.prompt("Capital of
| France?").text()) print(c.prompt("what language do they
| speak?").text())
|
| I wrote more about the new plugin system for adding extra models
| here: https://simonwillison.net/2023/Jul/12/llm/
| avereveard wrote:
| It's funny that these tools try to coerce LLM to use json as
| intermediate format.
|
| As long as you're cycling data between LLM unstructured text is
| going to be just fine.
|
| Have your tools accept natural language as well, and you're
| golden.
| savy91 wrote:
| Worst part of langchain is the "documentation". Especially the
| one about the javascript implementation
| teaearlgraycold wrote:
| Honestly just shut the whole thing down at this point.
| b33j0r wrote:
| I generally agree, but why so polemic?
|
| I mean, it starts by giving the full name of the original
| author... calls using his free software a waste of time...
| destroys the design as if tearing down someone's work who made
| bad decisions at every turn when making a brand-new thing that is
| FOSS.
|
| Did anyone else find that a bit strange? Did I miss the light-
| hearted tone buried somewhere?
|
| That said, strangely... useful examples and up-to-date detailed
| technical analysis that I like. I just don't get why this sector
| gets so nasty between people... fight the robots, guys! ;)
| doctoboggan wrote:
| I noticed the sentiment toward LangChain make an abrupt 180 as
| soon as they announced their funding. I don't think it's a
| conspiracy to ruin their value, more like HN readers were first
| interested in a cool open source project exploring this new
| field of generative AI, but now that they have millions the
| expectations change and they find themselves under more
| scrutiny.
| crooked-v wrote:
| A conspiracy seems far less likely to me than just people
| noticing they exist _because_ they got funding.
| Veen wrote:
| Disappointment? Langchain promises a lot, it's generated lots
| of hype, it's got a big VC investment. So it must be awesome.
| But when you try to use it, you find yourself wasting hours or
| days to discover there's nothing particularly exciting behind
| the curtain.
| chomp wrote:
| I don't know, I'm 100% against tearing down other people's FOSS
| work, but I think it's okay to be more critical once VC money
| starts flowing. At that point, it's a product jointly owned by
| venture capitalists for return on investment, and less a labor
| of love.
|
| Anyway, for those of us who've used LangChain a bit, I don't
| think anything in the article is revelatory, the codebase is
| structured as a first mover project, with all of the copy+paste
| and poor abstractions that come with it. It's absolutely great
| for prototyping and simple scripts, but I don't think I would
| use it in a production codebase, I found it very difficult to
| work around the bugs and wonky abstractions.
| minimaxir wrote:
| I think you're reading into the tone too much, but I address
| this very argument at the end.
|
| > No one wants to be that asshole who criticizes free and open
| source software operating in good faith like LangChain, but
| I'll take the burden. To be clear, I have nothing against
| Harrison Chase or the other maintainers of LangChain (who
| encourage feedback!). However, LangChain's popularity has
| warped the AI startup ecosystem around LangChain itself and the
| hope of OMG AGI I MADE SKYNET, which is why I am compelled to
| be honest with my misgivings about it.
| b33j0r wrote:
| Thanks for replying. I get your angle a bit better now, and
| as a sarcastic guy should have gotten it!
|
| My main headfake in this actually revolutionary-incremental
| advance over the past 8 or so months... has been more similar
| to yours than I read at first. Nice post!
| Terretta wrote:
| Thanks for making this:
|
| _" simpleaichat is a Python package for easily interfacing
| with chat apps like ChatGPT and GPT-4 with robust features
| and minimal code complexity. This tool has many features
| optimized for working with ChatGPT as fast and as cheap as
| possible, but still much more capable of modern AI tricks
| than most implementations"_
|
| https://github.com/minimaxir/simpleaichat
|
| Separately, in the article, typo expect->except here:
|
| _" LangChain uses about the same amount of code as just
| using the official openai library, expect LangChain
| incorporates more object classes for not much obvious code
| benefit."_
| gwern wrote:
| https://gwern.net/holy-war
|
| Anyone who's been burned by LangChain, especially now that it
| has VC funding, has to be worried that LangChain will become
| the cross-LLM standard library(tm), and they'll be dealing with
| it and endless patches to it for the rest of their lives.
| (Think systemd or NPM or Python packaging.) If it's as bad as
| described, the time to stop LangChain is to strangle it in the
| cradle, before it can get too far or risks finding a killer-
| app/niche which will immortalize it no matter how bad it is.
| [deleted]
| esafak wrote:
| They're well funded, so go ahead and criticize them.
|
| https://blog.langchain.dev/announcing-our-10m-seed-round-led...
| mschwarz wrote:
| Reading this was very cathartic, I was nodding along and laughing
| as I had the exact same journey of WTF. And all along I just
| assumed I was 100% of the problem.
|
| Hearing this perspective helps put my frustration in context. I
| need to lower my expectations and just get used to its quirks.
| Despite its issues I've had a ton of fun building with langchain
| and will keep using it.
| srdjanr wrote:
| Langchain is perfect to give you ideas for how to interact with
| LLMs, but for me it's been easier to implement everything myself
| than to use it.
| techwizrd wrote:
| I agree completely. I use it for inspiration and maybe a quick
| prototype to understand something, but I usually implement the
| pieces myself. Debugging LangChain performance and bugs is just
| an exercise in frustration.
| reissbaker wrote:
| LangChain is definitely verbose, and personally I don't use it.
| That being said, they have some pretty interesting tools the
| author didn't cover: their example selectors e.g. the
| MaxMarginalRelevance selector [1] is interesting, useful, and
| similar example selector tools become something close to
| necessary for managing large LLM applications.
|
| I wish the code quality was better, but poking around their docs
| does give pretty interesting ideas you can build yourself, even
| if you don't use LangChain. I think the release of OpenAI
| function calling has also just kinda sideswiped the need for
| large parts of these kind of frameworks -- you don't need much
| help in coercing to JSON or parsing anymore if you use the
| function calling API.
|
| 1:
| https://python.langchain.com/docs/modules/model_io/prompts/e...
| jrvarela56 wrote:
| Recent post on the same topic:
| https://news.ycombinator.com/item?id=36645575
___________________________________________________________________
(page generated 2023-07-14 23:00 UTC)