How to get Huggingface vector embedding in main workflow?

Problem Description

I would like to obtain the embedding vector of text directly within the main workflow in n8n. While n8n provides integrated embedding sub-nodes, I am uncertain how to retrieve the embedding vector from these nodes for use in the main workflow. Additionally, I am utilizing a Langchain code node to generate text embeddings, but I am unsure how to properly execute the code in this context.

I have two specific inquiries:

  1. Is there a method to directly acquire the embedding vector in the main workflow?
  2. How can I utilize the Langchain code node to generate an embedding vector for a specified text within the workflow?

Please share your workflow

The output returned by the last node

[
  {
    "text": "Hello World",
    "vector": {}
  },
  {
    "text": "Hi World",
    "vector": {}
  }
]

The Langchain code node run sucessfully, but the workflow keep executing and didn’t stop.

Information on your n8n setup

  • n8n version: [email protected]
  • Database (default: SQLite): SQLite
  • Running n8n: Docker
  • Operating system: Window

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @trinq!

There’s two ways how you can get embeddings into the main flow from Hugging Face:

  1. Http Request node
  2. Using Langchain Code node

I demonstrated both in this workflow:

Hope that helps!

Oleg