Live data from Hacker News

Re-implementing LangChain in 100 lines of code

blog.scottlogic.com

41–50 of 85 posts

Re: Re-implementing LangChain in 100 lines of code

#41
I got the chance to try Langchain as part of a hiring process. I was already having my eye on it for a personal projects though.

The moment I tried it and went through the docs, the entire abstraction feels weird for me. I know a bit here and there about LLM, but Langchain make me feels like Im learning something entirely new.

How agent and tools work and how to write one wasnt straightforward from the docs, and the idea of having an AI attach itself to an eval or writing its own error/hallucination-prone API request based on a docs doesnt give me a lot of confidence.

The hiring assignment specifically mentioned to use Langchain thought, so I did. But just as a glorified abstraction to call GPT and parses the NL output as JSON.

I did the actual API call, post-processing, etc. manually. Which I have granular control over it. Also cheaper in terms of token usages. You could say I ended writing my own agent/tool that doesnt exactly match Langchain specifications but it works.

I guess Langchain had its use case. But it feels pretty weird to use for me.

Re: Re-implementing LangChain in 100 lines of code

#42
I'm glad I wasn't the only one that felt Langchain had a ton of redundant abstractions engineered to gain clout for vc money. Here is an example:

AnalyzeDocumentChain[1] just wraps RecursiveCharacterTextSplitter[2]. It serves no real purpose except padding the api doc.

[1] https://js.langchain.com/docs/modules/chains/other_chains/an... [2] https://js.langchain.com/docs/modules/chains/other_chains/su...

Re: Re-implementing LangChain in 100 lines of code

#43

Given that the company has $200 million valuation, that is $2 million per line of code! just kidding. Still, I would like to understand $200 million valuation of langchain.ai.

VC's are in full blown FOMO mode for things they barely understand. Even the engineering backgrounds are pretty lost; imagine the finance backgrounds that have barely wrote a lick of code.

Re: Re-implementing LangChain in 100 lines of code

#44
I also was underwhelmed by langchain, and started implementing my own "AIPL" (Array-Inspired Pipeline Language) which turns these "chains" into straightforward, linear scripts. It's very early days but already it feels like the right direction for experimenting with this stuff. (I'm looking for collaborators if anyone is interested!)

https://github.com/saulpw/aipl

Re: Re-implementing LangChain in 100 lines of code

#45
post #32

As someone who has created several LLM-based applications running in production, my personal experience with langchain has been that it is too high of an abstraction for steps that in the end are actually fairly simple. And as soon as you want to slightly modify something to better accomodate your use-case, you are trapped in layers & layers of Python boiler plate code and unnecessary abstractions. Maybe our llm appl…

Comparing Langchain to Hugging Face Transformers is apples and oranges. One is for research, one is for production. Production ML requires more abstraction, not less.

I disagree. Production systems don't need to be full of AbstractSingletonProxyFactoryBeans which is basically what LangChain is. For example, Linux certainly isn't.

Re: Re-implementing LangChain in 100 lines of code

#46

I got the chance to try Langchain as part of a hiring process. I was already having my eye on it for a personal projects though. The moment I tried it and went through the docs, the entire abstraction feels weird for me. I know a bit here and there about LLM, but Langchain make me feels like Im learning something entirely new. How agent and tools work and how to write one wasnt straightforward from the docs, and the…

What type of position was the assessment for?

Re: Re-implementing LangChain in 100 lines of code

#47
post #28

I cannot praise Deepset Haystack enough for how simple they make things compared to LangChain, between the Preprocessor, the Reader/Retriever, and the PromptNode - the APIs, docs, and tutorials are quite easy to modify to your use-case. Not affiliated, just a happy defector from LangChain.

Is it open source? Wasn’t clear from the website.

Re: Re-implementing LangChain in 100 lines of code

#48
post #42

I'm glad I wasn't the only one that felt Langchain had a ton of redundant abstractions engineered to gain clout for vc money. Here is an example: AnalyzeDocumentChain[1] just wraps RecursiveCharacterTextSplitter[2]. It serves no real purpose except padding the api doc. [1] https://js.langchain.com/docs/modules/chains/other_chains/an... [2] https://js.langchain.com/docs/modules/chains/other_chains/su...

It's worse than that. The documentation is a confusing mess that completely omits the explanation of key default parameters and details. And the abstractions are horrendously brittle. And difficult to fix, because there are too many layers.

The best use of LangChain is probably just looking at the included prompts in the source code for inspiration.

Re: Re-implementing LangChain in 100 lines of code

#49

I got the chance to try Langchain as part of a hiring process. I was already having my eye on it for a personal projects though. The moment I tried it and went through the docs, the entire abstraction feels weird for me. I know a bit here and there about LLM, but Langchain make me feels like Im learning something entirely new. How agent and tools work and how to write one wasnt straightforward from the docs, and the…

LangChain and the ReAct paper that helped codify the implementation are both less than a year old.

A hiring assignment suggesting it is…weird.

Re: Re-implementing LangChain in 100 lines of code

#50
For me Langchain is glue code between a lot of commonly used LLM building blocks and prompts.

It is great to get a prototype 80% of the way there fast in order to validate an idea or run something short lived.

I suspect that, if you want to go further (simpler code, better control message length, reliability, etc), you will be better served by implementing the functionality you need yourself.

Post reply on HN