Face Matching Algorithms: ArcFace, CosFace and the Didit Face Match API
Face matching turns a face into an embedding and compares angles. ArcFace adds a fixed angular margin during training; CosFace subtracts a cosine margin. We charge $0.05 per check and return a 0 to 100 score, not a probability.

Contents
In this guide
Jump to the part you need.
This guide is for engineers and product leads adding 1:1 face comparison to onboarding, re-authentication or access control, and for anyone choosing between ArcFace, CosFace and earlier embedding methods. We charge $0.05 at list price for a standalone Face Match call. A full ID check costs $0.33 and includes the $0.05 Face Match step. The caveat that decides your design: a similarity score is only as good as the capture and the threshold you set, so pair it with liveness and a retry path.
Last updated: November 26, 2026. Prices checked against the live Didit price feed on November 26, 2026.
| What you need | Didit surface | Price | Documented call |
|---|---|---|---|
| Compare a selfie with an ID portrait, one shot | Face Match standalone API | $0.05 per check | POST /v3/face-match/ |
| Compare inside a hosted flow, with retries and coaching | Face Match step in a workflow | $0.05, one line of the $0.33 full ID check | FACE_MATCH feature |
| Check a single selfie for signs of liveness | Passive Liveness standalone API | $0.10 per check | POST /v3/passive-liveness/ |
| Check liveness inside a hosted flow | Active liveness in a workflow | $0.15 per check | LIVENESS feature |
| Find duplicates or blocked faces | Face Search 1:N | $0.05 per search | POST /v3/face-search/ |
Start free in the sandbox at https://business.didit.me/ (no sales call). Developers can connect Didit to an AI assistant through https://didit.me/developers/mcp/.
What you will have at the end
A working 1:1 comparison that takes two images, returns a similarity score from 0 to 100 with an Approved or Declined status, and applies a threshold you chose from your own data. The recommended method: run Face Match inside a Didit workflow with ID Verification and Liveness when a user is enrolling, so the ID portrait is the reference and the liveness selfie is the probe. Use the standalone POST /v3/face-match/ call when your system already holds both images, for example on re-authentication or on a manual review queue.
How a face becomes a number
A common pipeline detects and aligns the face, crops it, and feeds the crop to a model that produces a fixed-length embedding. The model determines the embedding size. Many systems normalize embeddings and compare them with cosine similarity. The backbone, the alignment method, the embedding size and the scoring method vary between systems, so treat any single recipe as one implementation rather than the definition.
Cosine similarity is the cosine of the angle between two vectors. A value of 1 means they point in the same direction, 0 means they are orthogonal, and a negative value means the angle exceeds 90 degrees. The operating threshold determines the match decision.
Verification is a threshold on that number. Identification is a nearest neighbour search over a database of stored embeddings.
FaceNet trains embeddings with triplets. SphereFace, CosFace and ArcFace train with a classifier over known identities and modify the target-class logit. At inference, the classifier can be discarded and embeddings compared directly. A deployed model's results also depend on its backbone, training data and preprocessing.
The formulas below describe training losses. Cosine similarity is one possible inference metric. We return a similarity score from 0 to 100. Treat it as a similarity score, and use labeled pairs to choose a threshold. Our public docs do not specify how the score is calculated.
FaceNet and the triplet loss
FaceNet, published by Schroff, Kalenichenko and Philbin at CVPR 2015, moved face recognition away from classifying identities. Each training sample is a triplet: an anchor image A, a positive image P of the same person, and a negative image N of someone else. The loss pushes the anchor closer to the positive than to the negative by at least a margin:
||f(A) - f(P)||² + α < ||f(A) - f(N)||²
Here f(x) is the embedding of image x and α is the margin. After training, verification is a threshold on the distance between two embeddings, and identification is a nearest neighbour search. Triplet mining is the hard part at scale: the number of possible triplets grows quickly, so training depends on choosing informative ones. The margin based losses below avoid triplet selection by turning the problem back into a classification objective.
ArcFace: an additive angular margin
ArcFace, published by Deng, Guo, Xue and Zafeiriou at CVPR 2019, normalizes both the embedding and the class weight vectors so they sit on a hypersphere. For the correct class the logit becomes s * cos(θ + m), where θ is the angle, m is the margin in radians and s is a scale factor. The paper reports a margin of about 0.5 radians with a scale of 64.
ArcFace adds a fixed angular margin to the correct class during training. This changes the classification objective on the unit hypersphere. At inference, compare the learned embeddings without adding the training margin. The margin is a property of the training objective, not something you apply to a similarity score.
An ArcFace embedding is the same object any other margin method produces: a normalized vector, 512 numbers in the published architecture, compared with cosine similarity. The margin changes how the vector is learned, not how you store or compare it.
CosFace: a cosine margin
CosFace, published by Wang and colleagues at CVPR 2018 as large margin cosine loss, CosFace subtracts a fixed margin from the cosine of the angle between the normalized embedding and the target-class weight, then scales the result to form the target logit: s * (cos θ - m). The margin sits in cosine space rather than angular space, and the implementation is often described as the simpler of the two because the margin is a straight subtraction.
Whether ArcFace or CosFace suits your data is an empirical question. Hold the backbone, the training data and the preprocessing fixed, then compare error rates on the same evaluation pairs at the same false match rate.
ArcFace, CosFace and the alternatives side by side
| Method | Where the margin sits | Honest best for | Practical note |
|---|---|---|---|
| Triplet loss (FaceNet, 2015) | An additive margin between the squared anchor-positive and anchor-negative distances | A distance-learning baseline when labeled identities and informative triplets are available | Triplet selection is the hard part at scale |
| SphereFace (2017) | Multiplicative angular margin | Reading the origin of margin based training | Later methods moved from multiplicative to additive margins |
| CosFace (2018) | Subtracted from the cosine of the target-class angle | Teams that want a simple margin implementation | Uses a fixed margin in cosine space during training |
| ArcFace (2019) | Added to the angle of the target logit | A reasonable baseline for 1:1 and 1:N comparison | Compare it with other losses using the same alignment, crops and backbone |
| AdaFace (2022) | Adjusted per sample during training | Datasets with many low quality captures | Uses feature norm as a quality proxy during training |
| Light CNN (2018) | Not margin based | Real time verification on limited hardware | Trades accuracy for speed and memory |
| VGGFace2 trained ResNet (2018) | Depends on the loss used on top | A pretrained backbone for your own training | It is a dataset and architecture, not a loss |
SphereFace introduced the angular margin idea in 2017 and AdaFace added a quality-adaptive margin in 2022. Neither a published margin value nor a benchmark number transfers to your users, so the comparison that counts is the one you run on your own pairs.
Choosing a threshold from your own pairs
The default decline threshold of 30 is a starting point, not a policy. Select your threshold against a false match target, then measure what it costs in false non-matches and review load. Keep selection and evaluation separate: pick the number on one set of labeled pairs, report the result on another.
- Collect genuine and impostor pairs from the capture flow you will actually run, not from a public benchmark. Genuine pairs come from the same person across your reference portrait and your live capture; impostor pairs come from different people.
- Score every pair with the API and record the score, the label and any warning.
- Set the unscorable captures aside. A pair that returns
NO_REFERENCE_IMAGE, or no score at all, is a capture failure to measure separately, not a false match. - On the selection half of the pairs, pick the threshold that meets your false match target. On the held-out half, report the false match rate, false non-match rate and unscorable rate. If you use hosted review or define a review band, report its share separately using hosted outcomes or by applying your review policy to the held-out scores.
- Apply the chosen threshold to the face comparison decision only. Account approval should also require the other checks your flow runs.
A worked example. With 4,000 genuine pairs and 40,000 impostor pairs, a threshold that produces 8 false matches gives a false match rate of 8 / 40,000 = 0.02%. If the same threshold rejects 120 genuine pairs, the false non-match rate is 120 / 4,000 = 3%. Put both numbers in the launch note, together with the review load and the count of unscorable captures.
Prerequisites before you run anything
- A Didit account and an application in the Business Console. Sandbox testing is free on every plan.
- An API key sent in the
x-api-keyheader. Missing or invalid credentials return 403 on this API, never 401. - Two images: the probe (a selfie) and the reference (an ID portrait or a stored photo). JPEG, PNG, WebP or TIFF, 5 MB maximum each, one clearly visible front facing face per image.
- For the hosted flow, a workflow that runs
ID_VERIFICATION,LIVENESSandFACE_MATCH. - A threshold you decided before launch, written down, with the false match and false non-match rates you measured.

Step by step: run a 1:1 face match
See our Face Match product page for an overview of 1:1 comparison.
Hosted flow: Face Match inside a session
- Create the application in the Business Console and copy its API key. Requests carry it in the
x-api-keyheader. - Add
FACE_MATCHto a workflow that also runsID_VERIFICATIONandLIVENESS. The ID portrait becomes the reference image and the liveness selfie becomes the probe. Setface_match_max_attemptsbetween 1 and 3; the default is 3. - Create the session with
POST /v3/session/, passingworkflow_id,vendor_dataandcallback. - Open
session.urlfor the user, or mount the Web or Mobile SDK. - Read
face_matches[]in the decision payload, either fromGET /v3/session/{sessionId}/decision/or from thestatus.updatedwebhook you configured. Each entry carries astatus,warningsand thenode_idof the workflow node that produced it. - Handle retry exhaustion. A fixable capture failure keeps the user on the step with
feedback_codesand an attempt count. When the attempt budget is spent, the computed status is applied, which can beDeclinedorIn Review.
Standalone call: both images already on your server
- Send the two images with the documented multipart call.
curl -X POST 'https://verification.didit.me/v3/face-match/' \ -H 'x-api-key: YOUR_API_KEY' \ -F 'user_image=@./selfie.jpg' \ -F 'ref_image=@./id_portrait.jpg' \ -F 'save_api_request=true' \ -F 'vendor_data=user-123' - Read
face_match.status,face_match.scoreandface_match.warningsfrom the response. - Choose the save path. With
save_api_requestat its default of true, we store the call as a session with both images. Use the returnedrequest_idas the session ID inGET /v3/session/{sessionId}/decision/, or read the decision from thestatus.updatedwebhook if you configured a webhook destination. With false, nothing is stored,request_idis a one-off correlation id, and the response is the only record you get. - Validate the request shape in the sandbox before you spend credit. On this endpoint, a sandbox key validates the request and then returns a static
Approvedmock for valid input; malformed requests can still return400. No images are scored, no session is saved and no credits are consumed. Use a live key for a real score.

Expected output
{
"request_id": "3f1c9a2e-...",
"face_match": {
"status": "Approved",
"score": 87.4,
"warnings": []
}
}
This is an abridged illustrative payload. The field names, statuses and warning codes are the documented ones; the values are not, and the response also carries image objects whose element schema we are not documenting here. If no face pair can be scored at all, the call still returns 200 with status: "Declined" and a NO_REFERENCE_IMAGE warning. score is null on the default save path, or 0 when save_api_request=false.
Inputs and outputs
| Field | Direction | Type and limits |
|---|---|---|
user_image | Input, required | Binary. The live or candidate face. tiff, jpg, jpeg, png or webp, 5 MB maximum. |
ref_image | Input, required | Binary. The reference portrait. Same formats and limit. |
face_match_score_decline_threshold | Input, optional | Float, default 30. Approve only above this value. |
save_api_request | Input, optional | Boolean, default true. Stores the call as a session and emits a webhook. |
rotate_image | Input, optional | Boolean. Set true when captures may be sideways or upside down. |
vendor_data | Input, optional | String. Your own user or case identifier. |
request_id | Output | Session id when the call is saved, one-off correlation id when it is not. |
face_match.status | Output | Approved or Declined on the standalone call. Session reports also use Not Started, In Progress, In Review, Abandoned and Kyc Expired. |
face_match.score | Output | Similarity from 0 to 100. When no pair can be scored, the value is null on the default save path and 0 with save_api_request=false. The documented response is Declined with NO_REFERENCE_IMAGE. |
face_match.warnings | Output | An array of warning objects. The risk field holds the code, such as LOW_FACE_MATCH_SIMILARITY, NO_REFERENCE_IMAGE, NO_FACE_DETECTED or MULTIPLE_FACES_DETECTED. |
Failure cases and how to recover
| Response | What happened | Recovery |
|---|---|---|
| 400 | Missing user_image or ref_image, file above 5 MB, or unsupported extension | Fix the request. Resize before upload; high resolutions are compressed to about 0.5 MB and do not improve accuracy. |
| 403 | Balance cannot cover the call, or the API key is wrong | The credit check runs before any image processing. Top up or replace the key. |
| 429 | Above the shared write budget of 300 requests per minute per key | Back off and retry with spacing. |
200, Declined, LOW_FACE_MATCH_SIMILARITY | The two faces do not match at your threshold | Do not approve. For eligible capture failures in a hosted session, prompt a guided retry while attempts remain. When the attempt budget is exhausted, use the computed Declined or In Review status. |
200, Declined, NO_REFERENCE_IMAGE | No pair could be scored, so the comparison has no result | NO_REFERENCE_IMAGE means no pair could be scored. Inspect both inputs and recapture any image without one clear, front-facing face. |
NO_FACE_DETECTED warning | A documented warning code meaning no usable face was found | Inspect both inputs and recapture any image without one clear, front-facing face: single face, front on, better light. |
MULTIPLE_FACES_DETECTED warning | A documented warning code meaning more than one face was in an image | Inspect both inputs and recapture any image without one clear, front-facing face: a solo shot with nobody in the background. |
| Session status In Review | The computed verdict needs a person | Route to your review queue with the score and warnings attached. |
Paid steps and review boundaries
We charge $0.05 at list price for Face Match, whether you call the standalone API or run it as a workflow step. See our pricing page. Inside a full ID check, face match is one of four lines that add to $0.33: ID document $0.15, passive liveness $0.10, face match $0.05, device and IP analysis $0.03. Each live standalone 200 response consumes one Face Match credit, including a decline with NO_REFERENCE_IMAGE. An insufficient-credit 403 occurs before image processing and consumes no credit. Sandbox calls consume no credit.
The review boundary matters more than the price. Automate approval only above your threshold. LOW_FACE_MATCH_SIMILARITY is a mismatch, not proof of fraud, and NO_REFERENCE_IMAGE is a capture failure, not a signal about the person. Duplicate account and blocklist signals do not come from this endpoint: they come from Face Search 1:N, or from the automatic 1:N search that runs with liveness and the silent front camera selfie during document capture. Keep those paths separate in your rules so a bad photo never becomes a fraud flag.

Worked cost example
Take a consumer app running 20,000 onboarding checks a month, with face match as part of the full ID check, plus 50,000 face comparisons a month on re-authentication.
- Full ID checks at list price: 20,000 x $0.33 = $6,600.
- Face match inside those checks: 20,000 x $0.05 = $1,000, already counted in the $6,600.
- Standalone re-authentication comparisons at list price: 50,000 x $0.05 = $2,500.
- List price usage subtotal: $6,600 + $2,500 = $9,100.
- On Growth, 4% off every price: full ID check $0.3168, so 20,000 x $0.3168 = $6,336; face match $0.048, so 50,000 x $0.048 = $2,400. Usage subtotal $8,736.
- On Scale, 10% off: full ID check $0.297, so 20,000 x $0.297 = $5,940; face match $0.045, so 50,000 x $0.045 = $2,250. Usage subtotal $8,190.
Now the plan fee and the credit. The Free plan costs $0 a month. The first organization created with an eligible work email for a company domain receives $10 in monthly credit. On Free, $9,100 of usage becomes $9,090 from top-ups after the credit. Growth is $99 a month with $115 of credit: $8,736 - $115 = $8,621 from top-ups, plus the $99 fee, so $8,720. Scale is $299 a month with $350 of credit: $8,190 - $350 = $7,840 from top-ups, plus the $299 fee, so $8,139. Credit is spent first, then top-ups, and monthly credit does not roll over.
Before you go live
- A valid request in the sandbox returns the static
Approvedmock, and a malformed request returns400. - A live key returns a real score, and the check shows up as a billable line in your usage.
- Low scores route to a retry or a review queue, not straight to a block.
- Unscorable pairs are counted separately from mismatches, whether the score comes back null or 0.
- Both save paths behave as expected: a saved call is retrievable through the decision endpoint and fires the webhook, and an unsaved call leaves no record.
- Your threshold is written down with the false match and false non-match rates you measured.
Sources
- Didit docs: Face Match API, 1:1 face comparison
- Didit docs: Face Match 1:1 overview, retries and thresholds
- Didit docs: Face Search 1:N overview
- Didit docs: Liveness Detection overview
- Didit docs: Data Models, face match report schema
- Didit docs: Webhooks and status.updated events
- Didit docs: Identity verification pricing
- Didit pricing page
- Didit pricing as JSON
- Schroff, Kalenichenko and Philbin. FaceNet: A Unified Embedding for Face Recognition and Clustering. CVPR, 2015.
- Liu, Wen, Yu, Li, Li and Zhao. SphereFace: Deep Hypersphere Embedding for Face Recognition. CVPR, 2017.
- Wang, Wang, Zhou, Ji, Gong, Zhou, Li and Liu. CosFace: Large Margin Cosine Loss for Deep Face Recognition. CVPR, 2018.
- Deng, Guo, Xue and Zafeiriou. ArcFace: Additive Angular Margin Loss for Deep Face Recognition. CVPR, 2019.
- Kim, Jain and Liu. AdaFace: Quality Adaptive Margin for Face Recognition. CVPR, 2022.
- Wu, He, Yu and Li. A Light CNN for Deep Face Representation with Noisy Labels. IEEE Transactions on Information Forensics and Security, 2018.
- Cao, Shen, Xie, Parkhi and Zisserman. VGGFace2: A Dataset for Recognising Faces across Pose and Age. IEEE International Conference on Automatic Face and Gesture Recognition, 2018.
The next step is a sandbox key, not a sales call. Create a free application at https://business.didit.me/, send one selfie and one ID portrait to POST /v3/face-match/, and check the request and response format against the abridged payload above. The sandbox returns a static Approved mock, so switch to a live key when you need a real score and a billable check.
Try it
Try this in the sandbox
Run the check this guide describes, free.
The product this post is about, taken from its topic. Run it free in the sandbox.
Author
Alejandro Rosas
Co-founder and CTO

Questions
Frequently asked questions
What is the most accurate face matching algorithm?
No loss function wins independently of the data it was trained on. ArcFace is a reasonable baseline because it separates identities in angular space and its training recipe is published. CosFace sits in the same family with a simpler margin, and AdaFace adjusts the training margin per sample. Hold the backbone, the training data and the preprocessing fixed, then compare error rates on the same pairs at the same false match rate.
What is ArcFace face recognition?
ArcFace is a training method for face recognition networks, published at CVPR 2019. It normalizes embeddings and class weights onto a hypersphere and adds a fixed angular margin to the correct class during training. At inference the classifier is discarded and the learned embeddings are compared directly, usually with cosine similarity.
What is an ArcFace embedding?
An ArcFace embedding is a fixed length numeric vector, 512 numbers in the published architecture, produced after the face is detected, aligned and cropped. The vector is normalized, so two embeddings are compared by the angle between them rather than raw distance. Training aims to make embeddings from the same person point in similar directions. Pose, lighting and other capture differences can lower similarity for a genuine pair.
What is CosFace and how does it differ from ArcFace?
CosFace subtracts a fixed margin from the cosine of the angle between the normalized embedding and the target-class weight, while ArcFace adds a margin to the angle itself. Both normalize features and weights and apply a scale factor before the classifier. Neither is universally better, so measure the difference on your own pairs at a fixed false match rate.
AdaFace vs ArcFace: which one should I use?
AdaFace uses the feature norm before normalization as a proxy for image quality and adjusts the training margin per sample, which reduces the emphasis on hard, low-quality examples relative to hard, high-quality examples. ArcFace uses one fixed angular margin for every sample. Compare both methods at the same false match rate on captures representative of your users before you pick one.
What is the difference between face verification and face identification?
Verification is a one to one comparison: does this face match this claimed identity, for example the portrait on an ID document. Identification is a one to many search: it scans a database and returns the closest candidates, or none. Onboarding and login are usually verification; duplicate account and blocklist checks are identification.
What factors affect face matching accuracy?
Resolution, lighting, head pose, occlusion from glasses, masks or hair, compression, and the age gap between the reference and the live capture. Two more matter in production: how diverse the training data is, and whether alignment and cropping run before the embedding is generated. We compress images to about 0.5 MB before processing. Our API docs recommend one clear, well-lit, front-facing face per image.
What should I set the face match threshold to?
The standalone Face Match API approves only scores strictly above face_match_score_decline_threshold, which defaults to 30. Treat that as a starting point and select your own value against a false match target using labeled genuine and impostor pairs from your capture flow. On held-out pairs, report the false match rate, false non-match rate and unscorable rate. If you use hosted review or a review band, measure review load separately from hosted outcomes or by applying your review policy to the held-out scores.
How much does a face match cost on Didit?
We charge $0.05 at list price, $0.048 on Growth and $0.045 on Scale for a Face Match check. Inside a full ID check it is one line of the $0.33 total, alongside ID document verification, passive liveness and device and IP analysis. Sandbox testing is free on every plan, and a standalone sandbox call returns a static Approved mock, so use a live key when you need a real score.
Can face matching be spoofed?
A printed photo, a replayed video or a mask can produce a matching embedding if nothing else is checked, because a face match only answers whether two faces correspond. Pair it with liveness: Passive liveness analyzes a single frame. 3D Flash analyzes reflected light without asking the user to move. The combined 3D Action & Flash method adds a prompted action. Test the attacks that matter for your capture flow, such as printed photos, screen replays and injected camera streams, and treat a liveness result as one signal about the capture rather than a guarantee that the camera input is genuine.
Does Didit tell me which loss function its face model uses?
Our public Face Match documentation does not identify the model's training loss. The API exposes a similarity score, a configurable decline threshold and warning codes. Hosted workflows also support guided retries for eligible capture failures.
What happens if the API finds no face in an image?
face_match.warnings is an array of warning objects, and the risk field holds the code. NO_REFERENCE_IMAGE means no pair could be scored. NO_FACE_DETECTED means no usable face was found, and MULTIPLE_FACES_DETECTED means more than one face was in frame. None of them is a fraud signal on its own: inspect both inputs and recapture any image without one clear, front-facing face.
Compliance built in
Audited, certified and attested.
We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center
- Regulation encoded into your flows
Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.
- Ready for AMLR
Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.
- Tested in Spain's Treasury sandbox
Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.
- Audited, not self-declared
iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.
Your obligations · 3 regions
SOC 2 Type 2
ISO 27001
iBeta Level 1 and Level 2
EU regulator attestation
FSM youth protection
GDPR
EBA remote onboarding
MiCA compatible
FIDO Alliance member
- AMLREU AML Regulation ready
Integration · Didit MCP
Run Didit from your own AI agent
Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.
- Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
- Run investigationsAsk why a session was declined, review cases, search people and companies.
- Change rulesCreate payment rules, test them on past data and switch them on.
- Pull reportsAsk for numbers, exports or the audit log.
Didit Academy


