liveBook · Manning

Siamese network architecture

As explained in Build an Advanced RAG Application (From Scratch)

A siamese network architecture consists of identical subnetworks with shared parameters that encode separate inputs for comparison.

A siamese network uses two identical subnetworks with shared parameters and weights to encode separate inputs for comparison. In Sentence-BERT, each sentence is encoded independently so the resulting embeddings capture semantic relationships. section 2.3.1

The architecture supports semantic comparison by:

  • Encoding each sentence independently with the same network. section 2.3.1
  • Learning to distinguish similar sentence pairs from dissimilar pairs. section 2.3.1
  • Using shared parameters to encourage embeddings that preserve semantic relationships. section 2.3.1

SBERT comparison path

Unlike BERT, which concatenates two sentences before processing them, Sentence-BERT independently encodes both sentences and calculates their cosine similarity.

How Build an Advanced RAG Application (From Scratch) covers it

How deep it goes
Explains twin subnetworks, shared weights, independent encoding, and pairwise similarity without detailing implementation.
Examples
Compares paired sentences through independent encoding and cosine similarity, and trains on similar or dissimilar pairs.
What it assumes
Builds on BERT while defining the siamese comparison mechanism and its shared-parameter behavior.
What you can do after
Evaluate semantic similarity by comparing independently generated sentence embeddings.
How it connects
Connects Sentence-BERT with BERT, sentence embeddings, semantic textual similarity, cosine similarity, and triplet loss.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an Advanced RAG Application (From Scratch). The section links point to the parts of the book it draws on.