HuggingFace, Cohere & LangFlow

This article covers creating a vector store using a web URL as the information source, with cohere as the LLM and HuggingFace Embeddings.

Cobus Greyling
4 min readJun 5, 2023

--

LangFlow is an IDE for LangChain, it is really an effortless way to experiment and prototype LLM & FM based flows. LangFlow offers a no-code drag-and-drop environment with a host of components and a chat interface.

LangFlow version 0.0.80 can be accessed via HuggingFace spaces using a browser with no installation required.

Alternatively version 0.0.81 can be installed with the command:

pip install langflow & run with the command: python -m langflow.

I used the MacOS terminal in the following way:

  • Create a virtual environment called langflow:

python3 -m venv langflow

  • Activate the environment:

source langflow/bin/activate

  • After use, deactivate and delete the virtual environment:

deactivate & sudo rm -rf langflow

The principle behind a vector store agent, is collect data from a source, map the text to a vector space, store it in a vector database and search the vector database in natural language.

The flow shown below, is a working flow of a vector store which is loading data from from a URL.

In this example HuggingFace is used for embeddings (sentence-transformers/all-mpnet-base-v2 mode) and cohere is implemented as the LLM.

You will see that the WebBaseLoader component is pointed to a Wikipedia URL. The WebBaseLoader loads all text from HTML pages into a document format which can be used downstream.

The HuggingFace sentence-transformers model, maps sentences & paragraphs to a vector space and can be used for tasks like clustering or semantic search.

The Cohere Large Language Model (LLM) is also used.

Chroma vector database is use for semantic search.

Below general questions can be asked pertaining to the url.

There are quite a few considerations with building LLM applications, these include:

  • For starters, cost, considering a LangFlow/LangChain application can interface to multiple APIs .
  • Hosting and latency, as local availability of APIs won’t be easy. Especially in the case of LLMs.
  • I would argue, that an extended conversational interface developed on LangFlow is not currently plausible.
  • However, via LangFlow one or multiple smart APIs can be built which are invoked from a traditional conversational UI when needed.

⭐️ Please follow me on LinkedIn for updates on LLMs ⭐️

I’m currently the Chief Evangelist @ HumanFirst. I explore and write about all things at the intersection of AI and language; ranging from LLMs, Chatbots, Voicebots, Development Frameworks, Data-Centric latent spaces and more.

https://www.linkedin.com/in/cobusgreyling
https://www.linkedin.com/in/cobusgreyling

--

--

Cobus Greyling
Cobus Greyling

Written by Cobus Greyling

I’m passionate about exploring the intersection of AI & language. www.cobusgreyling.com

Responses (2)