Live data from Hacker News

The Problem with LangChain

minimaxir.com

31–40 of 97 posts

Re: The Problem with LangChain

#31
post #3

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 n…

Why is the conversation tied to the model?

Re: The Problem with LangChain

#32
I use lambda over let over lambda (lolol)[1] like this (Clojure):

    (def chatgpt
      (-> (endpoint :chat "gpt-4" auth)
          (chat/set-opts [:endpoint] {:stream true})
          chat/retry
          chat/catch-unkown-commands
          ;; chat/history
          chat/string-input
          (chat/file-io "file.txt" :stream true)
          #_(chat/preserve-ctx chatgpt-ctx)))
These higher-level functions take as input the next function in the chain, and return a function that is responsible for calling it and takes a context hashmap as argument. Additionally, you can pass messages to these functions like :history/reset, impacting the atom defined in the let part of lolol. I use the same pattern for higher level constructs:

[1]https://letoverlambda.com/index.cl/guest/chap2.html#sec_6

Re: The Problem with LangChain

#34

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.

GPT-4 has good json support now. It’s nice to be able to give it a a schematic get structured json back.

Re: The Problem with LangChain

#35
I came to the same conclusion with author, decided to make port to Go. With a plan to just adopt the concepts and strip all the unnecessary complexity and lots things mentioned by the article. Datastore, chain, tools, model are pretty much implemented. However coming to Agent, I'm now wondering if it's the right way to do things. It does work, but is it efficient? At least I know it's not simple.

Re: The Problem with LangChain

#36
post #29

After running into these issues a few others and I wrote a typescript agent framework that I think significantly improves on LangChain in many ways: https://github.com/sciencecorp/buildabot/ It’s still very early days for software composing AI models and we almost certainly don’t have all the right metaphors yet. And I think there is a lot to be said for strong typing and simple, robust code!

I've played with langchain now for a couple weeks (with some of the llama-derivative local models and Oobadooba's native & openai apis + TextGen https://python.langchain.com/docs/modules/model_io/models/ll... ) and find it not-too-insanely-hard for an idiot like myself to figure out, though I'm just experimenting at this point with different models, esp. using tools, etc. I've found that some of the recommended prompts in the demos that, while perhaps working well with chatgpt/gpt4, need a lot of tweaking to work with with say WizardLM. But then I can get them working, so that's kinda neat.

I also played with huggingface's transformer agent (https://huggingface.co/docs/transformers/transformers_agents ) and thought it was a lot easier to useas far as the tools go, though is perhaps less capable for other things. I may go back to playing with that actually.

Re: The Problem with LangChain

#37
post #31
post #3

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 n…

Why is the conversation tied to the model?

Good question! It's because there's an aspect of conversations that differs between different models: the way the previous messages are injected into the context of the prompt.

I went back and forth on a bunch of different designs, but eventually decided to try to make it so that each plugin that implemented a new model would only have to subclass Model and add new methods.

You can see all of the design arguments I had with myself about this here, across the course of 129 pull requests comments: https://github.com/simonw/llm/pull/65

Re: The Problem with LangChain

#38
post #3

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 n…

Super pumped about this, Simon. Will be trying it this weekend. Any of the gpt4all models work, but need to duplicate the model files for now, right?

Re: The Problem with LangChain

#39
post #30
post #22

Earlier quoted context omitted.

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™, 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…

I’m a bit confused about why it’s a Python library and where its value proposition lies. If LLMs are going to be ubiquitous in app development, wouldn’t you expect Apple to release a Swift library that blows LangChain out of the water (similarly with Jetbrains/Kotlin, or Microsoft/C#).

Microsoft has Semantic Kernel: https://github.com/microsoft/semantic-kernel

> The SK extensible programming model combines natural language semantic functions, traditional code native functions, and embeddings-based memory unlocking new potential and adding value to applications with AI. > SK supports prompt templating, function chaining, vectorized memory, and intelligent planning capabilities out of the box.

I can't speak from experience whether it's better than LangChain, however.

Re: The Problem with LangChain

#40
post #3

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 n…

Super pumped about this, Simon. Will be trying it this weekend. Any of the gpt4all models work, but need to duplicate the model files for now, right?

Yeah I haven't figured out how to have it reuse the models from the desktop GPT4All installation yet, issue here: https://github.com/simonw/llm-gpt4all/issues/5
Post reply on HN