Filtering

Learn how to apply filters to RAG queries using tags in Hyper.


In Hyper, developers can utilize tags to filter and refine the data that is used when executing Retrieval-Augmented Generation (RAG) queries. This allows for more precise and contextually relevant responses from the language model by operating on a subset of the data that meets certain criteria.

Applying Tags for Filtering

Tags are applied to data within Hyper's system to categorize and organize it efficiently. Once these tags are in place, developers can use them to filter the data during RAG queries. This process ensures that the language model only considers data that is tagged with specific keywords or phrases that are relevant to the query at hand.

Constructing Filter Queries

Hyper allows for the construction of complex filters using logical operators such as "AND", "OR", and negation. This flexibility enables developers to create detailed criteria for data selection. The filter queries can be applied at the top level and can include nested logical structures to a depth of 3, allowing for sophisticated filtering logic.

Example Filter Query Structure

{
  "OR": [
    {
      "key": "topic",
      "value": "machine learning",
      "negate": false
    },
    {
      "key": "published",
      "value": "2023",
      "negate": false
    },
    {
      "key": "type",
      "value": "tutorial",
      "negate": true
    },
    {
      "AND": [
        {
          "key": "topic",
          "value": "natural language processing",
          "negate": false
        },
        {
          "key": "author",
          "value": "John Doe",
          "negate": false
        }
      ]
    }
  ]
}