> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mixpeek.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Search with your own Hugging Face model

> Pick an embedding model on Hugging Face and get a search over your documents that runs on it, with no serving code to write.

![Search with your own Hugging Face model](https://mixpeek.com/templates/bring-your-own-model/title-page.webp)

Pick an embedding model on Hugging Face and get a search over your documents that runs on it, with no serving code to write.

> [card] [Deploy in Studio](https://studio.mixpeek.com/manifests/apply?url=https%3A%2F%2Fmixpeek.com%2Ftemplates%2Fbring-your-own-model.namespace.yaml\&manifest_url=https%3A%2F%2Fmixpeek.com%2Ftemplates%2Fbring-your-own-model.namespace.yaml\&src=template-bring-your-own-model\&template=bring-your-own-model\&template_name=Search+with+your+own+Hugging+Face+model\&sync=1\&utm_source=docs\&utm_medium=template_deploy\&utm_campaign=mvs_onramp)
>
> Creates every resource below in your organization, with sample data.

> [card] [Download the manifest](https://mixpeek.com/templates/bring-your-own-model.namespace.yaml)
>
> `bring-your-own-model.namespace.yaml`, the file Studio and the API apply.

> [card] [Template page](https://mixpeek.com/templates/bring-your-own-model)
>
> The demo and the use case on mixpeek.com.

## At a glance

| | |
| - | - |
| **Creates** | 1 namespace, 1 custom extractor, 1 bucket, 1 collection, 1 retriever, 1 alert |
| **Extractors** | [`bge_small_hf`](https://docs.mixpeek.com/docs/extract/extractors) v1 |
| **Models** | [bge-small-en-v1.5](https://mixpeek.com/models/bge-small-en-v1-5) |
| **Daily spend budget** | 1 USD, set on the namespace. Queries are not capped. |
| **Sample data** | 4 objects, uploaded to `documents` when you apply |
| **Version** | 1.0, updated 2026-11-19 |

## How the pieces connect

Buckets hold what you upload, collections turn it into searchable documents, and retrievers answer queries over the collections.

```mermaid theme={null}
flowchart LR
  b0[("documents")]
  c1["document-embeddings<br/>bge_small_hf v1"]
  r2{{"document-search"}}
  b0 --> c1
  c1 --> r2
```

## Deploy it

> [tab] API
>
> **1. Get the manifest**
>
> ```bash theme={null}
> curl -sO https://mixpeek.com/templates/bring-your-own-model.namespace.yaml
> ```
>
> **2. Validate it**
>
> Validate runs every check apply runs and creates nothing. Fix each entry in `errors`, then run it again.
>
> ```bash theme={null}
> curl -X POST https://api.mixpeek.com/v1/manifest/validate \
>   -H "Authorization: Bearer $MIXPEEK_API_KEY" \
>   -F "manifest_file=@bring-your-own-model.namespace.yaml"
> ```
>
> **3. Apply it**
>
> Apply creates every resource in one call. `wait_for_seed=true` also waits until the sample objects are processed, so the first query below has documents to return.
>
> ```bash theme={null}
> curl -X POST "https://api.mixpeek.com/v1/manifest/apply?wait_for_seed=true" \
>   -H "Authorization: Bearer $MIXPEEK_API_KEY" \
>   -F "manifest_file=@bring-your-own-model.namespace.yaml"
> ```
>
> The response lists each resource with its outcome in `resources`. Apply refuses a resource that already exists and rolls the whole apply back, so to apply the file again over this namespace add `?mode=create_missing`, which creates only what is missing.

> [tab] Studio
>
> Open [Deploy in Studio](https://studio.mixpeek.com/manifests/apply?url=https%3A%2F%2Fmixpeek.com%2Ftemplates%2Fbring-your-own-model.namespace.yaml\&manifest_url=https%3A%2F%2Fmixpeek.com%2Ftemplates%2Fbring-your-own-model.namespace.yaml\&src=template-bring-your-own-model\&template=bring-your-own-model\&template_name=Search+with+your+own+Hugging+Face+model\&sync=1\&utm_source=docs\&utm_medium=template_deploy\&utm_campaign=mvs_onramp), sign in, choose where to deploy, and select **Apply to my workspace**. Studio shows each resource as it is created.

## Run the first query

Look up the namespace id by name, then run `document-search`. Check `status` and `warnings` along with `documents`: a run that times out still answers 200, with `status` `degraded`.

```bash cURL theme={null}
NAMESPACE_ID=$(curl -s https://api.mixpeek.com/v1/namespaces/bring-your-own-model \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" | jq -r .namespace_id)

curl -X POST https://api.mixpeek.com/v1/retrievers/document-search/execute \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{"inputs": {"query": "a monster made in a laboratory"}}' \
  | jq '{status, warnings, documents: [.documents[] | {document_id, score}]}'
```

```python Python theme={null}
import os, requests

AUTH = {"Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}"}
ns = requests.get("https://api.mixpeek.com/v1/namespaces/bring-your-own-model", headers=AUTH).json()

run = requests.post(
    "https://api.mixpeek.com/v1/retrievers/document-search/execute",
    headers={**AUTH, "X-Namespace": ns["namespace_id"]},
    json={"inputs": {"query": "a monster made in a laboratory"}},
).json()

print(run["status"], run["warnings"])  # "completed" on a clean run
for doc in run["documents"]:
    print(doc["document_id"], doc["score"])
```

```javascript JavaScript theme={null}
const auth = { Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}` };
const ns = await fetch("https://api.mixpeek.com/v1/namespaces/bring-your-own-model", { headers: auth }).then((r) => r.json());

const run = await fetch("https://api.mixpeek.com/v1/retrievers/document-search/execute", {
  method: "POST",
  headers: { ...auth, "X-Namespace": ns.namespace_id, "Content-Type": "application/json" },
  body: JSON.stringify({"inputs": {"query": "a monster made in a laboratory"}}),
}).then((r) => r.json());

console.log(run.status, run.warnings); // "completed" on a clean run
for (const doc of run.documents) console.log(doc.document_id, doc.score);
```

## Add your own data

Each object you add to a bucket is processed by every collection that reads it. This adds one object to `documents`. `NAMESPACE_ID` is the id from the namespace lookup above.

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/buckets/documents/objects?auto_process=true" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{"blobs": [{"property": "content", "type": "text", "data": "The text you want indexed."}]}'
```

```python Python theme={null}
import os, requests

HEADERS = {"Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}", "X-Namespace": os.environ["NAMESPACE_ID"]}

obj = requests.post(
    "https://api.mixpeek.com/v1/buckets/documents/objects",
    params={"auto_process": "true"},
    headers=HEADERS,
    json={
        "blobs": [
            {
                "property": "content",
                "type": "text",
                "data": "The text you want indexed."
            }
        ]
    },
).json()
print(obj["object_id"], obj["status"])  # PENDING until processing finishes
```

```javascript JavaScript theme={null}
const headers = {
  Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}`,
  "X-Namespace": process.env.NAMESPACE_ID,
  "Content-Type": "application/json",
};

const obj = await fetch("https://api.mixpeek.com/v1/buckets/documents/objects?auto_process=true", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "blobs": [
      {
        "property": "content",
        "type": "text",
        "data": "The text you want indexed."
      }
    ]
  }),
}).then((r) => r.json());
console.log(obj.object_id, obj.status); // PENDING until processing finishes
```

The object is `PENDING` until processing finishes, then `COMPLETED` or `FAILED`. [Buckets and objects](https://docs.mixpeek.com/docs/ingest/buckets.md) covers object states, retries and duplicates.

## Retrievers

### `document-search`

Type a question or a description and get the documents whose meaning is closest, ranked by your model's embeddings.

**Stages:** [`feature_search`](https://docs.mixpeek.com/docs/retrieve/stages#feature-search)

**Searches:** `document-embeddings`

| Input | Type | Required | Description |
| - | - | - | - |
| `query` | text | yes | What to look for; searched across every index below |

## Collections

Each collection runs one extractor over a bucket, or over another collection's documents.

> [accordion] document-embeddings
>
> Each document embedded by bge\_small\_hf, the Hugging Face model BAAI/bge-small-en-v1.5 that this manifest imports. Feeds document-search.
>
> **Reads** bucket `documents` with [`bge_small_hf`](https://docs.mixpeek.com/docs/extract/extractors) v1.
>
> **Inputs:** `text` ← `content`
>
> | Document field | Type |
> | - | - |
> | `text` | string |
> | `text_extractor_v1_embedding` | array\<number> |
> | `video_id` | string |
> | `title` | string |
> | `channel` | string |
> | `video_url` | string |
> | `duration_seconds` | integer |
> | `publish_date` | string |
> | `start_ms` | integer |
> | `end_ms` | integer |
> | `segment_index` | integer |
> | `heading_path` | string |
> | `chunk_kind` | string |
> | `code_language` | string |
> | `total_segments` | integer |

## Also created

**[Alerts](https://docs.mixpeek.com/docs/enrich/alerts-and-triggers.md)**

* `document-search-returning-nothing`: Emails the org notifications address (Settings -> Notifications; unset means opted out) when document-search has come back empty on its last five runs: the searches are matching no document, so the documents or their embeddings need a look.

> [accordion] Cost estimate at list price
>
> At 10,000 items a month (2 minutes or 10 pages each) and 100,000 queries, this template costs about **20.47 USD a month** (2.03 USD per 1,000 items). The namespace's daily spend budget pauses new batches before you pass it.
>
> | Part | USD a month |
> | - | - |
> | Processing | 20.25 |
> | Storage | 0.02 |
> | Queries | 0.20 |
> | Processing in `document-embeddings` | 20.25 |

## The manifest

Every resource above comes from this file. Change it and apply it again with `?mode=upsert` to update what exists. [Manifests](https://docs.mixpeek.com/docs/manage/manifests.md) documents each field.

```yaml bring-your-own-model.namespace.yaml expandable theme={null}
# bring-your-own-model: one manifest spins up the namespace.
# Platform manifest schema (GET /v1/discovery/schema). Validate with POST /v1/manifest/validate,
# apply with POST /v1/manifest/apply or the Deploy button. Wiring comes from the flow diagram:
# edges are bucket -> collection sources, collection -> retriever scope, retriever -> view.
# Applying a SECOND time, over a namespace this template already created: use
# POST /v1/manifest/apply?mode=create_missing, which creates what is missing and leaves
# what exists alone. The default, create_only, fails the WHOLE apply and rolls it back if
# any resource already exists, so an upgrade looks like a dead end without this. Use
# mode=upsert to also patch resources that exist but have drifted from this file.
version: '1.0'
metadata:
  name: bring-your-own-model
  description: "Namespace template bring-your-own-model. Generated from the flow diagram on mixpeek.com/templates/bring-your-own-model."

# The extractors the collections below run. A huggingface source is imported from the
# Hugging Face Hub at apply, into your organization's model registry, and served from it.
extractors:
  - name: bge_small_hf
    namespace: bring-your-own-model
    version: v1
    source:
      huggingface:
        repo: BAAI/bge-small-en-v1.5
        revision: "5c38ec7c405ec4b44b94cc5a9bb96e735b38267a"
namespaces:
  - name: bring-your-own-model
    description: "Everything below lives in this namespace."
    feature_extractors:
      - name: bge_small_hf
        version: v1
    # Daily spend budget, in dollars of what you are charged (1,000 credits a dollar).
    # New batches pause once the namespace has spent this much today; queries are not capped.
    # Raise it later on the namespace: PATCH /v1/namespaces/<id> {"spend_budget": {"daily_usd": N}}.
    budget:
      daily_usd: 1

# Data sources. A storage connection carries credentials, so it is created in Studio
# (or POST /v1/organizations/connections) and synced into the bucket named here.
#   your-documents: manual, continuous, one object per document: its text in content -> bucket documents
buckets:
  - name: documents
    namespace: bring-your-own-model
    description: "Meant to be fed by your-documents (manual, continuous): upload files here or write them through the API. Nothing arrives until you do."
    schema:
      properties:
        content:
          type: text
collections:
  - name: document-embeddings
    namespace: bring-your-own-model
    description: "Each document embedded by bge_small_hf, the Hugging Face model BAAI/bge-small-en-v1.5 that this manifest imports. Feeds document-search."
    source:
      type: bucket
      bucket: documents
    feature_extractor:
      name: bge_small_hf
      version: v1
      input_mappings:
        text: content
      field_passthrough: []
    enabled: true
retrievers:
  - name: document-search
    namespace: bring-your-own-model
    description: "Type a question or a description and get the documents whose meaning is closest, ranked by your model's embeddings."
    collections:
      - document-embeddings
    input_schema:
      query:
        type: text
        required: true
        description: "What to look for; searched across every index below"
    stages:
      - stage_name: search
        stage_id: feature_search
        parameters:
          searches:
            - feature_uri: "mixpeek://bge_small_hf@v1"
              query:
                input_mode: text
                value: "{{INPUT.query}}"
              top_k: 10
          fusion: rrf
          final_top_k: 10
    tags:
      - template:bring-your-own-model
alerts:
  - name: document-search-returning-nothing
    namespace: bring-your-own-model
    description: "Emails the org notifications address (Settings -> Notifications; unset means opted out) when document-search has come back empty on its last five runs: the searches are matching no document, so the documents or their embeddings need a look."
    source: system
    system_condition:
      type: retriever_no_results
      params:
        min_samples: 5
    notification_config:
      channels:
        - channel_type: email
      include_matches: true
      include_scores: true
    enabled: true

# Four public-domain books from the starter sample set, embedded by the Hugging
# Face model the extractors section imports, and the search they must answer.
seed:
  - bucket: documents
    max_objects: 4
    objects:
      - blobs: {content: samples/starter/texts/frankenstein.txt}
      - blobs: {content: samples/starter/texts/a-christmas-carol.txt}
      - blobs: {content: samples/starter/texts/alice-in-wonderland.txt}
      - blobs: {content: samples/starter/texts/adventures-of-sherlock-holmes.txt}
acceptance:
  max_cost_usd: 0.5
  steps:
    - name: documents-embedded-by-your-model
      kind: documents
      collection: document-embeddings
      expect: {min_documents: 4}
    - name: your-model-answers-a-search
      kind: query
      retriever: document-search
      inputs: {query: a monster made in a laboratory}
      expect: {min_results: 1}
```

## Hand it to an agent

Paste this prompt into Claude Code, Cursor or another coding agent. To give the agent this whole page instead, use **Copy page** in the menu at the top of the page, or point it at the page's Markdown at `https://mixpeek.com/docs/templates/bring-your-own-model.md`.

```text Prompt theme={null}
Set up the Mixpeek "Search with your own Hugging Face model" template in my organization. My API key is in MIXPEEK_API_KEY.
1. Download https://mixpeek.com/templates/bring-your-own-model.namespace.yaml to bring-your-own-model.namespace.yaml.
2. POST it to https://api.mixpeek.com/v1/manifest/validate as the multipart field manifest_file, with the header Authorization: Bearer $MIXPEEK_API_KEY. Fix every entry in errors and validate again.
3. POST the same file to https://api.mixpeek.com/v1/manifest/apply?wait_for_seed=true. Every entry in resources should be created.
4. GET https://api.mixpeek.com/v1/namespaces/bring-your-own-model and keep namespace_id. Send it as the X-Namespace header on every call below.
5. POST {"inputs": {"query": "a monster made in a laboratory"}} to https://api.mixpeek.com/v1/retrievers/document-search/execute. Read documents, check that status is completed, and print warnings.
Reference for this template: https://mixpeek.com/docs/templates/bring-your-own-model.md
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.