---
title: "Getting Started With Embeddings"
description: "Embeddings turn text or images into fixed-length vectors that capture meaning, so semantic similarity becomes a distance calculation."
url: "https://swe.quest/articles/getting-started-with-embeddings-f83c278b13779a68"
canonical: "https://huggingface.co/blog/getting-started-with-embeddings"
source: "Hugging Face"
published: "2022-06-23"
difficulty: "medium"
kind: "How-to"
reading_minutes: 11
tags: ["search","machine-learning","python","vector-search"]
---

# Getting Started With Embeddings

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-06-23, 11 min read, How-to. Original: [https://huggingface.co/blog/getting-started-with-embeddings](https://huggingface.co/blog/getting-started-with-embeddings)

## Summary

Embeddings turn text or images into fixed-length vectors that capture meaning, so semantic similarity becomes a distance calculation. A walkthrough builds a small FAQ matcher: it embeds 13 Medicare FAQs into 384-dimensional vectors with sentence-transformers/all-MiniLM-L6-v2 through the Hugging Face Inference API, hosts the vectors as a CSV dataset on the Hub, then embeds a user query and ranks the top 5 FAQs by cosine similarity with util.semantic\_search. Practical notes include retrying the first API call while the model loads, and using FAISS via add\_faiss\_index as an alternative search path.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)

## Prerequisites

- Python basics ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- REST API calls ([easy posts on API design](https://swe.quest/tags/api-design.md?difficulty=easy))

## Keywords

Sentence Transformers, all-MiniLM-L6-v2, Hugging Face Inference API, Hugging Face Hub, PyTorch, FAISS

## Related posts

- [Image Similarity with Hugging Face Datasets and Transformers](https://swe.quest/articles/image-similarity-with-hugging-face-datasets-and-transformers-cfa579cfca74f44c.md): Hugging Face · 2023-01-16 · Medium · 7 min read · Computer vision, Vector search, Search, Python
  An image similarity system can be built by embedding images with a fine-tuned Vision Transformer (CLS token from the last hidden state) and ranking candidates by cosine similarity against a query embedding.
- [Image search with 🤗 datasets](https://swe.quest/articles/image-search-with-datasets-7a6fd7ae6c6c63ce.md): Hugging Face · 2022-03-16 · Medium · 12 min read · Vector search, Computer vision, Python, Search
  A text-to-image search over 10,000 British Library book embellishments can be built by loading the images with the 🤗 datasets ImageFolder loader and embedding them with the CLIP ViT-B/32 model via sentence\_transformers.
- [Run Embedding Models and Unlock Semantic Search with Docker Model Runner](https://swe.quest/articles/run-embedding-models-and-unlock-semantic-search-with-docker-model-runner-9d62d61c93466830.md): Docker · 2025-12-01 · Medium · 6 min read · Vector search, Inference & serving, Search, RAG & retrieval, Containers
  Docker Model Runner can serve embedding models locally, so semantic search and RAG pipelines run without sending private data to a hosted API and without per-call costs.
- [Generate embeddings with Neon AI Gateway](https://swe.quest/articles/generate-embeddings-with-neon-ai-gateway-8da1f214a3b9e4fc.md): Neon · 2026-10-02 · Medium · 7 min read · RAG & retrieval, Vector search, PostgreSQL, LLMs
  Neon AI Gateway now serves embedding models on its OpenAI-compatible /v1/embeddings endpoint using the same branch-scoped credential as chat, accepting up to 150 inputs per request.
- [Vector Search with ClickHouse - Part 1](https://swe.quest/articles/vector-search-with-clickhouse-part-1-c538ccf9d6af206b.md): ClickHouse · 2023-05-31 · Easy · 14 min read · Vector search, Search, Machine learning
  Vector search replaces term-based inverted indexes, which use TF/IDF or BM25 scoring and can't capture meaning or handle vocabulary mismatch, with embeddings: arrays of floats where semantically similar text, images or audio sit close together under cosine or Euclidean distance.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
