Learning How LLM Apps are Built with LangChain and Databricks

The more that I learn about LLMs, the more I’m convinced that they are among the most consequential innovations in the history of computing, right up there alongside the relational database, the graphic user interface, and the internet. With LLMs on track to start influencing most spheres of human endeavor in the near future, my curiosity has been sparked to learn more about how LLM apps are built.

To dive deeper into the subject, I decided to take Databricks’ course titled Large Language Models: From Application to Production. Like Fast.ai, this is another notebook-driven course, where the instructors walk through Jupyter notebooks in order to give hands-on code demonstrations that illustrate key concepts. I’d glanced at a few different LLM courses online, but this one seemed like the best balance for my profile: moderately technical but more focused on applications than computer science details.

Here are a few of the most interesting things that I learned:

  1. For NLP applications, the main benefit of embeddings is that they allow you to quantify the similarity in meaning between different words or phrases. Words with similar meanings tend to appear in similar contexts, so analyzing the context in which words occur often allows for an inference of meaning. Embeddings are basically a compressed representation of this meaning.
  2. LLMs can act as “agents” that programmatically operate many different tools in order to complete tasks. What this means is that an LLM can take an instruction prompt in natural language and then programmatically invoke different tools in order to complete whatever task it’s been assigned. The LLM just needs to be provided with a description of the capabilities of each tool, as well as examples of code used to control those tools. In the class, we reviewed a sample notebook where the LLM was instructed to hit a search engine API to look up the results of a car race, transform the race results into a tabular format using pandas, build a random forest regressor to analyze that data and show what features were most predictive of winning the race, and then use a data visualization library to show a graph of the results. That’s the type of task that’d take a data scientist some time to do, and the LLM agent did it instantly. Mind blown.
  3. Multiple LLMs can be chained together to perform a composite task. One example task that we reviewed in the class was to summarize movie reviews and then do sentiment analysis on the summaries. Although a single LLM could be instructed to do both in one go, better results might be obtained by chaining together two different LLMs: one fine-tuned for summarization, and the other fine-tuned for sentiment analysis. In addition to improving the performance on each sub-task, this approach also allows for intermediate values to be analyzed, which can facilitate trouble-shooting, and incremental improvement. Examples like this helped me to realize that many applications that could potentially be performed by a single LLM will often consist of many different components chained together, including potentially multiple LLMs.
  4. Fine-tuning without re-training – Large foundation models are surprisingly capable of being fine-tuned to do specific tasks without undergoing re-training to update model weights. The two most talked about types of this fine-tuning are called few-shot learning and zero-shot learning.

With few-shot learning, you need only a few examples of the type of prompt you want the model to learn to reply to, as well as an exemplary response to each of those prompts. Using just that handful of prompt-response examples, the model learn to generate high-quality responses to new prompts of them same type without being re-trained in any way.

Zero-shot learning is even more impressive. Zero-shot learning is when you don’t provide the LLM with any examples of the type of response that you want it to generate, but only detailed instructions on the task you want it to perform. LLMs can then learn to follow those instructions without being given any explicit examples of how to do so. The fact that LLMs can be zero-shot learners is a big part of the reason why prompt engineering is so important.

The reason why LLMs are capable of few-shot and zero-shot learning is because they have extracted related concepts and reasoning patterns from their massive training data sets. These can be generalized and adapted to new situations.

  1. LLMOps – The course also briefly introduced LLMOps, which is basically just DevOps applied specifically to LLMs. LLMOps is basically a set of concepts and tools for productionizing and maintaining the LLM across its lifecycle. The toolset allow for quick and controlled ways of versioning, deploying, and monitoring data, models, and code. This kind of infrastructure is critical because any real-world business application of LLMs will involve a lot of experimentation and iteration, and the LLMOps discipline and tooling allows for that to be done in an organized fashion.

Leave a Reply

Your email address will not be published. Required fields are marked *