> For the complete documentation index, see [llms.txt](https://docs.metarank.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metarank.ai/reference/overview/recommendations/semantic.md).

# Semantic similarity

`semantic` is a content recommendation model, which computes item similarity only based on a difference between neural embeddings of items.

This model is useful for solving a cold-start problem of recommendations, as it requires no user feedback.

## Configuration

```yaml
- type: semantic
  encoder:
    type: bert
    model: metarank/all-MiniLM-L6-v2
    dim: 384 # embedding size
  itemFields: [title, description]
```

* itemFields: fields which should be used for embedding
* encoder: a method of computing embeddings

Metarank has quite limited support for embeddings:

* `bert` type of embeddings only supports ONNX-encoded models from sentence-transformers from HuggingFace
* `csv` type of embeddings allows loading a custom pre-made dictionary.

```yaml
- type: semantic
  encoder:
    type: csv
    dim: 384 # embedding size
    path: /opt/dic.csv
  itemFields: [title, description]
```

A dictionary should be a comma-separated CSV-formatted file, where:

* 1st column is product id
* 2 till N+1 columns - float values for N-dimentional embedding

Example:

```
p1,1.0,2.0,3.0
p2,2.0,1.5,1.0
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.metarank.ai/reference/overview/recommendations/semantic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
