Content uploaded by Ondrej Bruha
Author content
All content in this area was uploaded by Ondrej Bruha on Apr 21, 2025
Content may be subject to copyright.
Content uploaded by Ondrej Bruha
Author content
All content in this area was uploaded by Ondrej Bruha on Apr 21, 2025
Content may be subject to copyright.
Content uploaded by Ondrej Bruha
Author content
All content in this area was uploaded by Ondrej Bruha on Apr 21, 2025
Content may be subject to copyright.
Local Units as Domain Gates:
A Multineutral Algebra View on
Retrieval-Augmented Generation
Ondˇrej Br˚uha1
1Alpha Codes s.r.o. ondrej.bruha@alphacodes.eu
2025
Abstract
We show how to construct local units [1] for each semantic clus-
ter in an embedding space and how these units act as domain-specific
masks (gates) in Retrieval-Augmented Generation (RAG). The con-
struction is formulated purely algebraically, dispensing with imple-
mentation and revealing the direct connection to multineutral struc-
tures.
1 Preliminaries
Let E∈Rn×dbe a matrix whose rows eiare d–dimensional text embeddings
and let L∈ {−1,0, . . . , C −1}nbe cluster labels produced by any clustering
algorithm (e.g. HDBSCAN), where label −1 denotes noise.
For a fixed cluster index c≥0 define the index set Ic:= {i|Li=c}. We
assume Ic=∅(otherwise the cluster is absent). We denote the cardinality
of Icby k.
Denote by e(c)∈ {0,1}dthe local unit of cluster c; components are defined
as for some ϵ > 0
e(c)
j:= (1 iff1
kPi∈Ic|Eij |> ϵ,
0 otherwise. (1)
1
Thus e(c)
j= 1 precisely when at least one member of the cluster exhibits
non-zero activity in dimension j.
2 Gating with Local Units
Given a query embedding q∈Rd, its cluster-gated variant is
q
c:= q⊙e(c),(2)
where ⊙is the Hadamard (component-wise) product. The operation is idem-
potent and commutative inside the multineutral field determined by the em-
bedding space and the masking vectors.
Relevance test. Let scbe the cosine similarity between qcand the nearest
neighbour vector retrieved inside the cluster c. If scfalls below a threshold
τwe discard the cluster; otherwise, the corresponding passages are included
in the RAG context.
3 Algebraic Properties
1. Idempotence. e(c)⊙e(c)=e(c)by definition.
2. Commutativity. e(c)⊙e(d)=e(d)⊙e(c)for all c, d.
3. Local unity. For every embedding xbelonging to cluster cwe have
x⊙e(c)=x, because every non–zero coordinate of xsurvives the mask
according to (1).
These three facts show that the set {e(c)}c≥0forms a system of local units in
the sense of multineutral algebra [1].
4 Discussion
Local units are extremely cheap to compute and store; a single pass over
the embeddings suffices. Although cruder than centroids or soft masks, they
work well when the dominant goal is to filter away irrelevant dimensions
rather than to re-weight them.
Future work will explore smooth relaxations e(c)
j∈[0,1] that allow differ-
entiable learning of mask values.
2
References
[1] Bruha, Ondrej. (2025). Locally Regular Algebraic Struc-
tures: A Unified Approach to Multineutral Groups and Fields.
10.13140/RG.2.2.32459.50729.
3