# Low-noise RAG

Much of what search hands a model is filler. MillionShort lets you cut the popular, repetitive layer out of retrieval and see what was removed.

[RAG noise](https://millionshort.com/docs/glossary/what-is-rag-noise) is retrieved text that looks relevant and adds nothing: ten pages that restate the same source, listicles written to rank, pages that mention your keywords in passing. A model given noisy context writes a bland answer or a wrong one, and it spends tokens doing it.

## The problem

Most of the noise comes from one place. General search rewards popularity, and the most popular sites are often the ones that summarize, aggregate and repeat. Re-ranking the list afterwards does not help much, because the pages you wanted were never in it. The fix is to change which sites can answer.

## How MillionShort addresses it

- **Remove the popular layer.** [`remove_top_sites: N`](https://millionshort.com/docs/search/remove-top-sites) removes every result whose site is among the N most popular, from 0 to 1,000,000. What remains is the [long tail](https://millionshort.com/docs/glossary/what-is-long-tail-search): specialist sites, personal sites, forums and small publishers. Check `popularity` on what comes back to see the cut at work; the count in `summary.removed.popularity` stays 0 on some sources, `web` among them.
- **Block and bury.** `exclude_domains` blocks up to 25 sites outright. `bury_domains` moves sites down without removing them, and `boost_domains` moves trusted ones up. See [Lenses](https://millionshort.com/docs/search/lenses).
- **Keep the kinds of page you want.** `page_types` and `topics` filter by what a page is and what it is about. `exclude_page_types` and `exclude_topics` remove the kinds you never want, such as listicles.
- **Screen on signals.** Every result has a [`popularity` bucket and a `risk` label](https://millionshort.com/docs/search/popularity-and-risk). `risk` is null for a site with no label. Results from sites with the most serious labels are removed before you see them and counted in `summary.removed.risk`. `exclude_risky: true` drops every result whose site carries any label.
- **Search where noise is low.** The `smallweb` source is small independent sites only. `academic`, `medical` and `law` are specialist sources. You can search up to 5 of the [13 sources](https://millionshort.com/docs/search/sources) in one call.
- **Check the result.** `explain: true` is free and adds `why` to each result, so you can see whether a rule you set did what you meant.

## A low-noise call

The web and the small web without the 100,000 most popular sites, articles only among the `web` results (the page-type filter acts on `web` and `news`, so the response names `smallweb` in a `filter_not_applied` warning), with no site that carries a risk label and one site buried:

```bash
curl https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "sourdough starter hydration",
    "sources": ["web", "smallweb"],
    "remove_top_sites": 100000,
    "page_types": ["articles"],
    "bury_domains": ["example.com"],
    "exclude_risky": true,
    "max_chars_per_result": 1200,
    "explain": true
  }'
```

```python
import os

from millionshort import MillionShort

client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])

r = client.search(
    "sourdough starter hydration",
    sources=["web", "smallweb"],
    remove_top_sites=100000,
    page_types=["articles"],
    bury_domains=["example.com"],
    exclude_risky=True,
    max_chars_per_result=1200,
    explain=True,
)

seen = set()
for hit in r.results:
    if hit["site"] in seen:
        continue
    seen.add(hit["site"])
    print(hit["site"], hit["popularity"]["bucket"], hit.get("why", []))

print(r.summary["removed"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/search', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "query": "sourdough starter hydration",
    "sources": [
      "web",
      "smallweb"
    ],
    "remove_top_sites": 100000,
    "page_types": [
      "articles"
    ],
    "bury_domains": [
      "example.com"
    ],
    "exclude_risky": true,
    "max_chars_per_result": 1200,
    "explain": true
  }),
});
if (!res.ok) throw new Error(`POST /v1/search failed: ${res.status}`);
const { data } = (await res.json()) as {
  data: { results: { position: number; title: string; url: string }[] };
};
for (const hit of data.results) console.log(hit.position, hit.title, hit.url);
```

The same call as a tool of the MCP server:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search",
    "arguments": {
      "query": "sourdough starter hydration",
      "sources": [
        "web",
        "smallweb"
      ],
      "remove_top_sites": 100000,
      "page_types": [
        "articles"
      ],
      "bury_domains": [
        "example.com"
      ],
      "exclude_risky": true,
      "max_chars_per_result": 1200,
      "explain": true
    }
  }
}
```

The loop keeps one passage per site, and `exclude_risky` leaves out any site that carries a risk label, which are two cheap ways to raise [source diversity](https://millionshort.com/docs/glossary/what-is-source-diversity). The Python SDK is not published to a package registry yet; the `curl` request works today.

## Choosing N

There is no single right value. Start at 10,000 and compare the list with the unfiltered one for a dozen of your own queries. Raise N when the same aggregators still appear, lower it when good reference sites disappear. For questions where the popular answer is the right one, leave it at 0, or use `only_top_sites` to do the reverse.

## What it does not do

- **It does not judge pages.** `remove_top_sites` works on how popular a site is, not on how good a page is. Small sites can be wrong too, so keep your own checks.
- **No live fetch in a search.** Snippets go up to 2,000 characters, and `include_content: true` adds the page text we hold to `web` and `news` results. Fetching a page as it is now is what [Extract](https://millionshort.com/docs/extract/parameters) is for, as a separate call.
- **No generated answers from a search.** Your model writes; for an answer written by us, [Agent](https://millionshort.com/docs/agent) is a separate, metered call.
- **Keyword retrieval, periodic refresh.** Retrieval matches words, and the web source is refreshed periodically, not continuously, with no dates on web results.

## Read next

- [RAG with MillionShort](https://millionshort.com/docs/search/guides/rag) and [Long-tail research](https://millionshort.com/docs/search/guides/long-tail-research), the guides.
- [Remove the top sites](https://millionshort.com/docs/search/remove-top-sites), the concept in full.
- Glossary: [What is RAG noise?](https://millionshort.com/docs/glossary/what-is-rag-noise) and [What is long-tail search?](https://millionshort.com/docs/glossary/what-is-long-tail-search)
