Please rotate your device

To continue exploring this website, please rotate your device to a vertical orientation

SID-2

SID.ai/SID-2

Agentic search model that finds and ranks relevant documents. 2x faster than SID-1. 8x faster and 20x cheaper than frontier models at equivalent accuracy.

Model APIlarge language

SID-2 is a model trained to excel at one task: search. Given a question, a set of search tools, and a dataset, it runs iterative queries and returns a ranked list of relevant documents. Common use cases include legal, financial services, healthcare, compliance, e-commerce, customer support, and enterprise search.

Compared to SID-1, SID-2 delivers higher retrieval quality at approximately half the latency. Developers can configure reasoning effort (low, medium, high) and optimize for NDCG, F1, or Recall@N. SID-2 works with any search backend without requiring reindexing.

For more information and benchmarks, see the SID-2 Technical Report.

python
import os
import uuid

from openai import OpenAI
from sid import DocumentCache
from sid.document_cache import SNIPPET_SIZE_DEFAULT

# SID-2 is served through the OpenAI Responses API (not chat completions).
client = OpenAI(
    base_url="https://inference.baseten.co/v1",
    api_key=os.environ["BASETEN_API_KEY"],
)

MODEL = "sid/sid-2"
MAX_TURNS = 10
# "f1" (precision) | "ndcg" (recall) | "recall@<n>" for n in 1,2,5,10,20,50
REWARD = "f1"
REASONING_EFFORT = "low"  # "low" | "medium" | "high"

# The system prompt: edit the first sentence to describe your data; keep the steps.
INSTRUCTIONS = (
    "You are an expert research assistant that is given a question and must use "
    "the provided search tools to find all documents needed to answer the "
    "question.\n"
    "\n"
    "Steps:\n"
    "1. Reflect on what information is needed to answer the question and use the "
    "search tools to find documents. Each document has an id.\n"
    "2. Repeat step 1 until all documents necessary and sufficient to answer the "
    "question have been found. Take as many turns and searches as needed – you "
    "can make multiple searches per turn! Most questions will require multiple "
    "turns. Many will need more.\n"
    "3. Use the report_helpful_ids tool to report the most helpful document ids. "
    "List the most helpful document ids first (important!).\n"
    "\n"
    "The episode ends once report_helpful_ids is called."
)

# Tool descriptions go in `tools`; SID-2 does not read tool behavior from the
# system prompt.
SNIPPET_SIZE_DESCRIPTION = (
    f"Words shown per result snippet (default {SNIPPET_SIZE_DEFAULT}). "
    f"Must be a positive integer. "
    f"Pass a larger value to see more of each document."
)

SEARCH_TOOL = {
    "type": "function",
    "name": "search",
    "description": (
        "Semantic (vector) search over the dataset. Best for conceptual or "
        "paraphrased queries: a long, descriptive query of what you want beats a "
        "few keywords; use text_search when you know the distinctive words a "
        "match would contain. Result ids may be ranged references 'id#start:end' "
        "naming the exact character span of the document shown; stretches you "
        "have already been shown are replaced by '[seen: \"#start:end\"]' markers "
        "instead of repeating, and doc_length gives the document's total "
        "character count."
    ),
    "parameters": {
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "The query to search the dataset with",
            },
            "limit": {
                "type": "integer",
                "description": "The number of results to return",
            },
            "snippet_size": {
                "type": "integer",
                "description": SNIPPET_SIZE_DESCRIPTION,
            },
        },
        "required": ["query"],
    },
}

TEXT_SEARCH_TOOL = {
    "type": "function",
    "name": "text_search",
    "description": (
        "Full-text keyword search over the dataset, ranked by BM25. Provide the "
        "terms you want matched as plain words separated by spaces: the "
        "distinctive content words a matching document would contain. Result ids "
        "may be ranged references 'id#start:end' naming the exact character span "
        "of the document shown; stretches you have already been shown are "
        "replaced by '[seen: \"#start:end\"]' markers instead of repeating, and "
        "doc_length gives the document's total character count."
    ),
    "parameters": {
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "Plain space-separated content words to match (BM25).",
            },
            "limit": {
                "type": "integer",
                "description": "The number of results to return",
            },
            "snippet_size": {
                "type": "integer",
                "description": SNIPPET_SIZE_DESCRIPTION,
            },
        },
        "required": ["query"],
    },
}

READ_TOOL = {
    "type": "function",
    "name": "read",
    "description": (
        "Search results show only short snippets. Read up to 10,000 characters "
        "of a document per call. A bare ID starts at character 0; a ranged "
        "reference starts at its requested offset. Use further ranged reads to "
        "continue."
    ),
    "parameters": {
        "type": "object",
        "properties": {
            "id": {
                "type": "string",
                "description": (
                    "The id of the document to read. Also accepts a ranged "
                    "reference 'id#start:end' (character offsets, e.g. "
                    "'123456#800:1600') to read only that part of the "
                    "document's text; a range running past the end of the "
                    "document is trimmed to the part that overlaps it."
                ),
            },
        },
        "required": ["id"],
    },
}

# The fixed terminal tool: do not change its name, description or parameters.
REPORT_TOOL = {
    "type": "function",
    "name": "report_helpful_ids",
    "description": (
        "Report the most helpful document ids from the search results. This is "
        "required in the last step. Each id may be reported at most once; "
        "repeated ids are penalized. Ids may be whole documents ('123456') or "
        "ranged references ('123456#800:1600'); a ranged reference counts as its "
        "whole document, so there is no need to strip the '#start:end' part."
    ),
    "parameters": {
        "type": "object",
        "properties": {
            "ids": {
                "type": "array",
                "description": (
                    "The ids of the most helpful documents from the search results."
                ),
                "items": {"type": "string"},
            },
        },
        "required": ["ids"],
    },
}

TOOLS = [SEARCH_TOOL, TEXT_SEARCH_TOOL, READ_TOOL, REPORT_TOOL]

# Few-shot demonstrations, sent on every request. Provide at least one per tool.
TOOL_EXAMPLES = [
    {
        "caption": "Example: a semantic search with a long, descriptive query:",
        "name": "search",
        "arguments": {
            "query": (
                "the city where the first sub-four-minute mile was run "
                "on an outdoor track"
            ),
            "limit": 5,
        },
    },
    {
        "caption": "Example: a keyword search:",
        "name": "text_search",
        "arguments": {"query": "indoor mile record 3:59 track", "limit": 5},
    },
    {
        "caption": "Example: reading one character range:",
        "name": "read",
        "arguments": {"id": "placeholder_1#800:1600"},
    },
    {
        "caption": "Example: ending the episode with a report:",
        "name": "report_helpful_ids",
        "arguments": {"ids": ["placeholder_1", "placeholder_2", "placeholder_3"]},
    },
]


# --- Connect these two functions to your retrieval backend ---
# Return full chunks as dicts with "id", "content", and any display fields
# (e.g. "title"), best first.
def vector_search(query: str, limit: int = 5) -> list[dict]:
    """Semantic (embedding) search. Return the documents your backend matched."""
    raise NotImplementedError("Connect `vector_search` to your retrieval backend.")


def keyword_search(query: str, limit: int = 5) -> list[dict]:
    """Full-text (BM25) search. Return the documents your backend matched."""
    raise NotImplementedError("Connect `keyword_search` to your retrieval backend.")


# The SDK renders <doc> blocks: short model-facing ids, BM25 snippets, and
# [seen: ...] masking. `read` is served from the same cache, so it never touches
# your backend.
cache = DocumentCache(range_mode="lenient")  # one cache per episode


def render_results(
    results: list[dict],
    query: str,
    snippet_size: int = SNIPPET_SIZE_DEFAULT,
) -> str:
    rendered = []
    for result in results:
        document = dict(result)
        data_id = document.pop("id")
        if data_id not in cache:
            cache.add_document(data_id, document)
        view = cache.apply_snippet(
            data_id, "content", query, snippet_size=snippet_size
        )
        rendered.append(view.render_xml())
        cache.update_seen(view)
    if not rendered:
        return "No results found. Try a different query."
    return "\n".join(rendered)


# One request, sent unchanged on every turn of the episode; only `input` grows.
request = dict(
    model=MODEL,
    max_output_tokens=4096,
    store=False,  # you own the conversation; resend it every turn
    include=["reasoning.encrypted_content"],  # echo reasoning items back verbatim
    instructions=INSTRUCTIONS,
    tools=TOOLS,
    reasoning={"effort": REASONING_EFFORT},
    extra_body={"sid": {"tool_examples": TOOL_EXAMPLES, "reward": REWARD}},
    # New session id per episode.
    extra_headers={"x-session-affinity": uuid.uuid4().hex},
)

history = [
    {
        "role": "user",
        "content": (
            "In which cities were the indoor and outdoor 4 minute mile "
            "records set?"
        ),
    },
]

response = client.responses.create(input=history, **request)
print(response.model_dump_json(indent=2))

Output

json
{
  "id": "resp_xxxx",
  "object": "response",
  "created_at": 1785271508,
  "status": "completed",
  "model": "sid/sid-2",
  "output": [
    {
      "type": "reasoning",
      "id": "rs_xxxx",
      "content": [],
      "summary": [],
      "encrypted_content": "ttrs1_xxxx"
    },
    {
      "type": "function_call",
      "id": "fc_xxxx",
      "call_id": "call_xxxx",
      "name": "search",
      "arguments": "{\"query\": \"4 minute mile record indoor and outdoor\", \"limit\": 5}",
      "status": "completed"
    },
    {
      "type": "function_call",
      "id": "fc_xxxx",
      "call_id": "call_xxxx",
      "name": "search",
      "arguments": "{\"query\": \"city where the indoor mile record under four minutes was set\", \"limit\": 5}",
      "status": "completed"
    },
    {
      "type": "function_call",
      "id": "fc_xxxx",
      "call_id": "call_xxxx",
      "name": "text_search",
      "arguments": "{\"query\": \"outdoor mile world record four minutes city\", \"limit\": 5}",
      "status": "completed"
    }
  ],
  "output_text": "",
  "incomplete_details": null,
  "error": null,
  "instructions": "You are an expert research assistant that is given a question and must use the provided search tools to find all documents needed to answer the question. ...",
  "max_output_tokens": 4096,
  "parallel_tool_calls": true,
  "reasoning": {
    "effort": "low",
    "summary": null
  },
  "store": false,
  "temperature": null,
  "tool_choice": "auto",
  "tools": [
    {
      "type": "function",
      "name": "search",
      "...": "..."
    },
    {
      "type": "function",
      "name": "text_search",
      "...": "..."
    },
    {
      "type": "function",
      "name": "read",
      "...": "..."
    },
    {
      "type": "function",
      "name": "report_helpful_ids",
      "...": "..."
    }
  ],
  "top_p": null,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 1412,
    "input_tokens_details": {
      "cached_tokens": 1280
    },
    "output_tokens": 118,
    "output_tokens_details": {
      "reasoning_tokens": 36
    },
    "total_tokens": 1530
  },
  "metadata": {},
  "user": null
}