Using a AI workflow to find relevant tags from db

How can I effectively implement AI for context tagging using an existing database of tags before creating new ones?

I’m working on a project to explore if AI can contextualise text by tagging it with relevant metadata. My goal is for the AI to first search an existing database of tags and use them, only creating new tags if no relevant ones are found.

Example Workflow:

  • Input Text: House bed-rm temp window C
  • Database Structure:
Key Value Description
locationType House Specifies the type of location.
RoomType Bedroom Specifies the type of room.
Equipment Window Specifies the equipment or object.
Measure Temperature The type of measurement.
Unit Celsius The unit for the measurement.
  • AI Goal: Match existing tags first. If none fit, create a new tag with proper key-value mapping.

Example Tagging Process:

  1. The AI parses the input text:
    • House maps to locationType: House.
    • bed-rm maps to RoomType: Bedroom.
    • temp maps to Measure: Temperature.
    • window maps to Equipment: Window.
    • C maps to Unit: Celsius.
  2. The output tags from the database are:
    • locationType: House
    • RoomType: Bedroom
    • Equipment: Window
    • Measure: Temperature
    • Unit: Celsius

Case with New Tag Creation:

  • Input Text: Office conf-room humidity sensor %

  • AI Process:

    • Office doesn’t exist → Creates locationType: Office.
    • conf-room doesn’t exist → Creates RoomType: Conference Room.
    • humidity exists → Measure: Humidity.
    • sensor doesn’t exist → Creates Equipment: Sensor.
    • % exists → Unit: Percentage.
  • Updated Database After Tag Creation:

Key Value Description
locationType House Specifies the type of location.
locationType Office Specifies the type of location.
RoomType Bedroom Specifies the type of room.
RoomType Conference Room Specifies the type of room.
Equipment Window Specifies the equipment or object.
Equipment Sensor Specifies the equipment or object.
Measure Temperature The type of measurement.
Measure Humidity The type of measurement.
Unit Celsius The unit for the measurement.
Unit Percentage The unit for the measurement.

Questions:

  1. AI Implementation: How can I configure an AI model to prioritise using the tags from the database and only create new ones when no relevant match exists?
  2. Using n8n: How can I use n8n ( Version 1.72.1)to orchestrate this workflow (e.g., querying the database, passing text to the AI, managing tag creation)?
  3. Best Practices: Are there any best practices or tools to ensure consistency and avoid redundant tag creation?

Any advice, suggestions, or examples of similar workflows would be greatly appreciated! Thank you!

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: