CodeContent

The latest in-depth technical AI news & concepts

Member-only story

Using HuggingFace, OpenAI, and Cohere models with Langchain

6 min readMay 6, 2024

--

Photo by Eyasu Etsub on Unsplash

Langchain has been becoming one of the most popular NLP libraries, with around 30K starts on GitHub. I have recently tried it myself, and it is honestly amazing. If you are not familiar with Langchain, it is a library that helps developers build applications powered by large language models (LLMs). It does this by providing a framework for connecting LLMs to other sources of data, such as the internet or your personal files. This allows developers to chain together multiple commands to create more complex applications.

In this tutorial, we are going to be creating a question-answering model. This is pretty much what we are going to cover:

  1. Load hugging face transformer & embeddings
  2. Create a long chain index and fit it into our data
  3. Create a chain and ask it questions

Note that the current Langchain-HuggingFace ecosystem only supports text-generation and text2text-generation models according to the docs, so we will just go with that:

There exists two Hugging Face LLM wrappers, one for a local pipeline and one for a model…

--

--

CodeContent
CodeContent

Published in CodeContent

The latest in-depth technical AI news & concepts

Mostafa Ibrahim
Mostafa Ibrahim

Written by Mostafa Ibrahim

Software Eng. University College London Computer Science Graduate. Passionate about Machine Learning in Healthcare. Top writer in AI