Recency space encodes timestamp type data measured in seconds and in unix timestamp format. Recency space is utilized to encode how recent items are. Use period_time_list to mark the time periods of interest. Items older than the largest period_time are going to have uniform recency score. (0 or negative_filter if set) You can use multiple period_times to give additional emphasis to sub time periods. Like using 2 days and 5 days gives extra emphasis to the first 2 days. The extent of which can be controlled with the respective weight parameters. Unit weights would give double emphasis on the first 2 days, 1 and 0.1 weights respectively would give tenfold importance to the first 2 days. All items older than 5 days would get 0 or negative_filter recency score. Negative_filter is useful for effectively filtering out entities that are older than the oldest period time. You can think of the value of negative_filter as it offsets that amount of similarity stemming from other spaces in the index. For example setting it -1 would offset any text similarity that has weight 1 - effectively filtering out all old items however similar they are in terms of their text.

Constructor

RecencySpace(timestamp, time_period_hour_offset=timedelta(0), period_time_list=None, aggregation_mode=InputAggregationMode.INPUT_AVERAGE, negative_filter=0.0)

Parameters

timestamp
Timestamp | Sequence[Timestamp]
required
A set of Timestamp objects. The actual data is expected to be unix timestamps in seconds. It is a SchemaFieldObject not regular python ints or floats.
time_period_hour_offset
timedelta
default:"timedelta(0)"
Starting period time will be set to this hour. Day will be the next day of context.now(). Defaults to timedelta(hours=0).
period_time_list
list[PeriodTime] | PeriodTime | None
default:"None"
A list of period time parameters. Weights default to 1. Period time to 14 days.
aggregation_mode
InputAggregationMode
default:"InputAggregationMode.INPUT_AVERAGE"
The aggregation mode of the recency embedding. Possible values are: maximum, minimum and average. Defaults to InputAggregationMode.INPUT_AVERAGE.
negative_filter
float
default:"0.0"
The recency score of items that are older than the oldest period time. Defaults to 0.0.

Inheritance

Inheritance Chain:
  • RecencySpace
  • Space
  • HasTransformationConfig
  • HasLength
  • Generic
  • HasSpaceFieldSet
  • ABC

Properties

allow_similar_clause
bool
Whether this space allows similarity clauses in queries.
space_field_set
SpaceFieldSet
The space field set for this recency space.
transformation_config
TransformationConfig[int, int]
Configuration for transforming timestamp values into vectors.