Edit

Half-precision float support in vector data type

Applies to: SQL Server 2025 (17.x) Azure SQL Database Azure SQL Managed Instance SQL database in Microsoft Fabric

The vector data type supports an optional base type. By default, vector uses float32. You can specify float16 (half-precision) when reduced precision is acceptable. float16 provides a more compact representation that can reduce storage and improve performance.

A half-precision floating-point vector is an array of numbers in which each number uses the 16-bit float16 floating-point format. This representation uses half the storage of the 32-bit float32 format. Use float16 to reduce storage and memory consumption for workloads such as embeddings, semantic search, and machine learning.

float16 provides less numerical precision and a smaller numeric range than float32. This tradeoff makes float16 suitable for approximate similarity scenarios, but less appropriate for workloads that require high-precision arithmetic or exact numerical fidelity.

Syntax

To use half-precision values, specify float16 as the vector base type:

column_name VECTOR ( <dimensions> [ , <base_type> ] ) [ NOT NULL | NULL ]

If you omit <base_type>, the default is float32.

Key benefits of float16

  • Increased dimensionality

    The SQL Database Engine supports vectors with up to 3,996 dimensions when using float16, compared to 1,998 dimensions when using float32. The additional dimensions support embeddings generated by models that produce more than 1,998 values.

  • Reduced storage and memory footprint

    Storing vector elements in a 16-bit format reduces the storage required compared to float32. This reduction makes it practical to store and query high-dimensional vectors at scale.

  • Storage efficiency and precision control

    Choose the base type that is appropriate for the workload:

    • Use float16 for compact storage when reduced precision is acceptable.
    • Use float32 for general use and workloads that require greater precision.

Feature availability

  • Half-precision (float16) vectors are generally available in Azure SQL Database, Azure SQL Managed Instance, and SQL database in Microsoft Fabric. No preview configuration is required.

  • Half-precision (float16) vectors are available in preview in SQL Server 2025. Enable the PREVIEW_FEATURES database scoped configuration option before using VECTOR(..., float16). For more information, see PREVIEW_FEATURES = { ON | OFF }.

    ALTER DATABASE SCOPED CONFIGURATION
    SET PREVIEW_FEATURES = ON;
    GO
    

Examples

A. Define vector columns

The following example defines separate columns that use the default float32 base type and the explicit float16 base type:

CREATE TABLE dbo.Float32Vectors
(
    id int PRIMARY KEY,
    VectorColumn vector(3)
);

CREATE TABLE dbo.Float16Vectors
(
    id int PRIMARY KEY,
    VectorColumn vector(3, float16)
);

B. Store and compare float16 vectors

The following example creates a table with a float16 vector column, inserts sample data, and uses VECTOR_DISTANCE to find the three closest vectors:

CREATE TABLE dbo.Articles
(
    id int PRIMARY KEY,
    title nvarchar(100),
    content nvarchar(max),
    embedding vector(5, float16)
);

INSERT INTO dbo.Articles (id, title, content, embedding)
VALUES
    (1, N'Intro to AI', N'This article introduces AI concepts.',
        '[0.1, 0.2, 0.3, 0.4, 0.5]'),
    (2, N'Deep Learning', N'Deep learning is a subset of ML.',
        '[0.2, 0.1, 0.4, 0.3, 0.6]'),
    (3, N'Neural Networks', N'Neural networks are powerful models.',
        '[0.3, 0.3, 0.2, 0.5, 0.1]'),
    (4, N'Machine Learning Basics', N'ML basics for beginners.',
        '[0.4, 0.5, 0.1, 0.2, 0.3]'),
    (5, N'Advanced AI', N'Exploring advanced AI techniques.',
        '[0.5, 0.4, 0.6, 0.1, 0.2]');

DECLARE @QueryVector vector(5, float16) =
    '[0.3, 0.3, 0.3, 0.3, 0.3]';

SELECT TOP (3)
    id,
    title,
    VECTOR_DISTANCE('cosine', @QueryVector, embedding) AS distance
FROM dbo.Articles
ORDER BY distance;

Note

A vector index requires at least 100 rows with non-NULL vector values. For requirements and examples, see CREATE VECTOR INDEX.

C. Inspect vector base type metadata

The following query confirms actual base type and dimensions of a vector column:

--Inspect Vector Base type Metadata in sys.columns
SELECT name AS column_name,
       system_type_id,
       user_type_id,
       vector_dimensions,
       vector_base_type,
       vector_base_type_desc
FROM sys.columns
WHERE object_id = OBJECT_ID('dbo.Articles');

Output columns:

  • vector_dimensions: Number of dimensions defined for the vector.

  • vector_base_type: Internal numeric code for the base type:

    • 0 = float32
    • 1 = float16
  • vector_base_type_desc: Human-readable description of the base type.

Supported implicit & explicit conversion

SQL Server supports both implicit and explicit conversion from varchar, nvarchar, and json strings to VECTOR(<dimension_count>, float16), as long as the vector is declared with an explicit dimension count.

DECLARE @j AS JSON = '[1.0, 2.0, 3.0]';
DECLARE @v AS VECTOR(3, float16);
SET @v = CAST (@j AS VECTOR(3, float16)); -- Explicit conversion from JSON to float16

DECLARE @v1 AS VARCHAR (50) = '[1.0, 2.0, 3.0]';
DECLARE @v2 AS VECTOR(3, float16);
SET @v2 = CAST (@v1 AS VECTOR(3, float16)); -- Explicit conversion from VARCHAR to float16

DECLARE @v1 AS NVARCHAR (50) = N'[1.0, 2.0, 3.0]';
DECLARE @v2 AS VECTOR(3, float16);
SET @v2 = CAST (@v1 AS VECTOR(3, float16)); -- Explicit conversion from NVARCHAR to float16

Implicit Conversion is supported only when the target vector type is fully declared.

-- Implicit conversion from VARCHAR to float16
DECLARE @v1 AS VARCHAR (50) = '[1.0, 2.0, 3.0]';
DECLARE @v2 AS VECTOR(3, float16);
SET @v2 = @v1;

-- Implicit conversion from NVARCHAR to float16
DECLARE @v1 AS NVARCHAR (50) = N'[1.0, 2.0, 3.0]';
DECLARE @v2 AS VECTOR(3, float16);
SET @v2 = @v1;

--From JSON_ARRAY to VECTOR
DECLARE @v3 AS VECTOR(3, float16) = JSON_ARRAY(1.0, 2.0, 3.0);

Unsupported or error-prone scenarios

The following examples highlight common errors and limitations when working with half-precision float vector data type in SQL Server.

Explicit and implicit conversion between base types float32 and float16

SQL Server currently does not support implicit conversion between VECTOR(float32) and VECTOR(float16).

Additionally, explicit conversion using CAST or CONVERT is currently blocked.

DECLARE @v1 AS VECTOR(3, float16);
DECLARE @v2 AS VECTOR(3, float32) = '[1.0, 2.0, 3.0]';
SET @v1 = CAST (@v2 AS VECTOR(3, float16)); -- Explicit conversion from float32 to float16

The following error is returned:

Error: Msg 42238, Level 16, State 1, Line 61
Conversion of vector from data type float32 to float16 is not allowed.

Dimension mismatch

Conversion between vectors with mismatched dimensions isn't allowed and raises a dimension mismatch error.

DECLARE @v1 AS VECTOR(3, float16) = '[1.0, 2.0, 3.0]';
DECLARE @v2 AS VECTOR(4, float16) = NULL;
SET @v1 = @v2;

The following error is returned:

Error: Msg 42204, Level 16, State 1, Line 10
The vector dimensions 4 and 3 do not match

Null handling

If a vector is declared without a dimension count, assigning a value to it raises an error.

This example works:

DECLARE @v1 AS VECTOR(3, float16) = NULL;
DECLARE @v2 AS VECTOR(3, float16) = '[1.0, 2.0, 3.0]';
SET @v1 = @v2;

However, if the dimension count isn't specified, it raises an error:

DECLARE @v1 AS VECTOR(float16) = NULL;
DECLARE @v2 AS VECTOR(3, float16) = '[1.0, 2.0, 3.0]';
SET @v1 = @v2;

Out-of-range values

Out-of-range values for float16 (for example, values above 65504.0) raise an error during assignment.

DECLARE @v AS VECTOR(3, float16) = '[1.0, 2.0, 70000.0]';

The following error is returned:

Input JSON contains out-of-range values for float16

Mixed base types in functions

Mixed base types in functions like VECTOR_DISTANCE aren't supported and raises a type error.

DECLARE @v1 AS VECTOR(3, float32) = '[1.0, 2.0, 3.0]';
DECLARE @v2 AS VECTOR(3, float16) = '[1, 2, 3]';

SELECT VECTOR_DISTANCE('euclidean', @v1, @v2);

The following error is returned:

VECTOR_DISTANCE does not support different base types

Unsupported architecture

Arm64 architectures don't support float16. Using this type causes a runtime error.

DECLARE @v1 AS VECTOR(3, float16) = '[1.0, 2.0, 3.0]';
DECLARE @v2 AS VECTOR(3, int) = '[1, 2, 3]';

SELECT VECTOR_DISTANCE('euclidean', @v1, @v2);

The following error is returned:

float16 is not supported on ARM64 architecture

SIMD overflow

Single instruction, multiple data (SIMD)-based operations, such as AVX2 or SSE4.2, might produce overflow errors if values exceed representable ranges.

DECLARE @v AS VECTOR(8) = '[-2.9e+38, ..., 2.9e+38]';

SELECT VECTOR_NORM(@v, 'norm1');

The behavior depends on the ARITHABORT setting:

  • ARITHABORT ON results in an error
  • ARITHABORT OFF results in NULL

Tools support

SQL Server Management Studio (SSMS) doesn't currently distinguish between float32 and float16 in the user interface. Query sys.columns to confirm the base type used by a vector column.

Driver support

The following drivers support native binary transport for float16 vectors:

Use these driver versions or later to send and receive float16 vectors in native binary format. Drivers that don't support native float16 transport can work with vectors represented as varchar(max) JSON arrays.

Note

All limitations that apply to the default vector type with the float32 base type also apply to VECTOR(..., float16), unless otherwise noted.