Faiss logo

Faiss

Community
AlexAI-MCP
faiss

Facebook AI Similarity Search — ultra-fast vector similarity search for large-scale local embedding retrieval without a database server.

Overview

PublisherAlexAI-MCP
Repositoryhermes-CCC
Skill namefaiss
Stars
134
Forks
22
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by AlexAI-MCP on GitHub. Read the source before you install it.

Installation

Install the Faiss AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/AlexAI-MCP/hermes-CCC/tree/master/skills/faiss
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AlexAI-MCP/hermes-CCC.git /tmp/hermes-CCC
mkdir -p .claude/skills
cp -r /tmp/hermes-CCC/skills/faiss .claude/skills/faiss
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Faiss in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Faiss on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Faiss is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

FAISS — Fast Vector Similarity Search

FAISS (Facebook AI Similarity Search) is a library for efficient similarity search over large collections of vectors. No server required — runs entirely in-process.

When to Use FAISS

  • Millions of vectors, need maximum speed
  • Can't run a server (embedded use case)
  • Research / prototyping at scale
  • Custom index types (HNSW, IVF, PQ)

Setup

bash
pip install faiss-cpu        # CPU only
pip install faiss-gpu        # GPU (requires CUDA)
pip install sentence-transformers numpy

Basic Flat Index (Exact Search)

python
import faiss
import numpy as np
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("all-MiniLM-L6-v2")  # dim=384
DIM = 384

# Build index
documents = [
    "Python async programming",
    "Machine learning with PyTorch",
    "Docker container management",
    "GraphQL API design",
]

embeddings = model.encode(documents).astype(np.float32)

# Flat L2 index (exact, brute force)
index = faiss.IndexFlatL2(DIM)
index.add(embeddings)
print(f"Index size: {index.ntotal}")

# Search
query = "how to do async in Python?"
q_vec = model.encode([query]).astype(np.float32)

distances, indices = index.search(q_vec, k=3)
for i, idx in enumerate(indices[0]):
    print(f"[{distances[0][i]:.3f}] {documents[idx]}")

Cosine Similarity (Normalize first)

python
# For cosine similarity: normalize vectors, use IndexFlatIP (inner product)
def normalize(vecs):
    norms = np.linalg.norm(vecs, axis=1, keepdims=True)
    return vecs / np.maximum(norms, 1e-8)

embeddings_norm = normalize(embeddings.astype(np.float32))
index_cos = faiss.IndexFlatIP(DIM)
index_cos.add(embeddings_norm)

q_norm = normalize(model.encode([query]).astype(np.float32))
scores, indices = index_cos.search(q_norm, k=3)

IVF Index (Fast Approximate Search)

python
# For large datasets (>100k vectors)
N_CLUSTERS = 100  # sqrt(N) is a good heuristic

quantizer = faiss.IndexFlatL2(DIM)
index_ivf = faiss.IndexIVFFlat(quantizer, DIM, N_CLUSTERS)

# Must train before adding
index_ivf.train(embeddings)
index_ivf.add(embeddings)
index_ivf.nprobe = 10  # search 10 clusters (higher = more accurate, slower)

distances, indices = index_ivf.search(q_vec, k=5)

HNSW Index (Best Speed/Accuracy Tradeoff)

python
index_hnsw = faiss.IndexHNSWFlat(DIM, 32)  # 32 = M parameter
index_hnsw.add(embeddings)

distances, indices = index_hnsw.search(q_vec, k=5)

Save and Load Index

python
# Save
faiss.write_index(index, "my_index.faiss")

# Load
index = faiss.read_index("my_index.faiss")

With Metadata (store separately)

python
import pickle

# FAISS only stores vectors — store metadata separately
metadata = [{"id": i, "text": doc} for i, doc in enumerate(documents)]

# Save both
faiss.write_index(index, "vectors.faiss")
with open("metadata.pkl", "wb") as f:
    pickle.dump(metadata, f)

# Load and query
index = faiss.read_index("vectors.faiss")
with open("metadata.pkl", "rb") as f:
    metadata = pickle.load(f)

distances, indices = index.search(q_vec, k=3)
for idx in indices[0]:
    print(metadata[idx]["text"])

GPU Acceleration

python
res = faiss.StandardGpuResources()
index_gpu = faiss.index_cpu_to_gpu(res, 0, index)  # GPU 0
distances, indices = index_gpu.search(q_vec, k=5)

Index Selection Guide

IndexSizeSpeedAccuracyUse Case
IndexFlatL2AnySlow100%<100k vectors, exact needed
IndexFlatIPAnySlow100%Cosine similarity
IndexIVFFlatLargeFast~95%100k–10M vectors
IndexHNSWFlatMediumVery fast~99%Best general choice
IndexIVFPQHugeFastest~90%Billions, memory-constrained

Frequently asked questions

What does the Faiss AI skill do?

Facebook AI Similarity Search — ultra-fast vector similarity search for large-scale local embedding retrieval without a database server.

Why use Faiss on TypingMind?

Because you install it once and use it with any model. Faiss is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Faiss in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/AlexAI-MCP/hermes-CCC/tree/master/skills/faiss. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Faiss?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Faiss?

As many as you like. As long as a model supports skills, you can use Faiss with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Faiss AI skill free?

Yes. It is published on GitHub by AlexAI-MCP under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇