---
title: RXNFP
description: >-
  Generate reaction fingerprints and search a reference reaction index by
  similarity with an RXNBERT transformer model.
tags:
  - rxnfp
---

RXNFP encodes a chemical reaction into a fixed-length fingerprint vector, letting you compare and search reactions by their transformation pattern. Reach for it when you need raw similarity or machine-learning features over reactions rather than named categories. Where [Reaction Classifier](/docs/reaction-classifier) returns human-readable reaction names, RXNFP returns the underlying vectors — and Reaction Classifier falls back to RXNFP's similarity search when its own classifier is uncertain. See [what you can achieve](/docs/capabilities#chemistry) for the full set.

## RXNFP overview

RXNFP generates a 256-dimensional vector representation of a chemical reaction from its reaction SMILES, using a fixed RXNBERT transformer model. The fingerprint enables cosine-similarity comparison between reactions, and a separate similarity-search tool looks up a query reaction against a pre-built reference index.

Two tools cover this:
- **Fingerprinting** (`rxnfp` / `rxnfp_fingerprint`) — turn one or more reaction SMILES into fingerprint vectors.
- **Similarity search** (`rxnfp_similarity`) — take a single query reaction and return the top-k most similar reactions from a reference index built from ORDerly reaction data, above a minimum similarity threshold.

## How it works

 BERT["RXNBERT transformer<br/>tokenization, encoding, pooling"]
    BERT --> FP["256-D fingerprint vector<br/>(float32)"]
    FP --> Direct["Direct output: per-reaction fingerprint"]
    FP --> Search["rxnfp_similarity: cosine search<br/>against the ORDerly reference index"]`}
  caption="A reaction SMILES is encoded by RXNBERT into a 256-D fingerprint, returned directly or used to search a reference index of known reactions."
/>

The reaction SMILES is tokenized and processed through the RXNBERT transformer. The hidden state is pooled into a fixed 256-dimensional float vector that captures the chemical transformation pattern. Similar reactions produce similar vectors.

## When to use RXNFP

**Use fingerprinting (`rxnfp_fingerprint`) when:**

- You need a fixed-length reaction representation as an ML feature.
- You want to cluster or visualize a reaction set yourself, downstream of the platform.

**Use similarity search (`rxnfp_similarity`) when:**

- You want the most similar known reactions to a novel transformation, ranked by cosine similarity.
- You are chaining from [Reaction Classifier](/docs/reaction-classifier)'s low-confidence fallback path.

**Use Reaction Classifier instead when:**

- You need named reaction categories (e.g., "Suzuki coupling").
- You need atom mapping or reaction templates.
- You need condition suggestions from literature.

## Limitations

- Fingerprints encode the overall transformation but may not distinguish subtle regiochemistry differences.
- Very long reaction SMILES are truncated at the tokenizer's limit, which may lose information.
- `rxnfp_similarity` searches a fixed reference index (built from ORDerly reaction data); it does not compute a pairwise matrix across an arbitrary set of reactions you submit.
- The model was trained primarily on organic chemistry reactions; inorganic and enzymatic reactions may produce less meaningful fingerprints.

## Citations

> Schwaller P, Probst D, Vaucher AC, Nair VH, Kreutter D, Laino T, Reymond JL. Mapping the Space of Chemical Reactions Using Attention-Based Neural Networks. *Nat Mach Intell*. 2021;3:144-152. doi: [10.1038/s42256-020-00284-w](https://doi.org/10.1038/s42256-020-00284-w)

## Chat Usage

### Example Prompts

- "Generate a reaction fingerprint for CC(=O)Cl.OCC>>CC(=O)OCC"
- "Find the most similar reaction in the database to this novel transformation"

### Workflow Chaining

- **Feeds into**: ML feature engineering, similarity search
- **Accepts from**: AiZynthFinder (retrosynthetic step SMILES), Reaction Classifier (low-confidence fallback)

## FAQ

### What does the fingerprint tool return?

  A 256-dimensional float vector per reaction, from a single fixed RXNBERT model — there's no model-variant selector.

### How does similarity search work?

  `rxnfp_similarity` takes one query reaction and returns the top-k most similar reactions (default 10, up to 100) from a reference index, above a minimum similarity threshold (default 0.7). It does not return a pairwise matrix across reactions you submit yourself.

### Can I batch-fingerprint reactions?

  Yes — pass an array of reaction SMILES to get one fingerprint per reaction in a single job.

## Read next
