Logo de Retrieval Rag

Retrieval Rag

Comunidade
nahid-sparktales
retrieval-rag

Build and fix retrieval that actually returns the right passage — structure-aware chunking, one pinned embedding model, lexical plus vector search fused, reranking, and a recall measurement that is run separately from the generator. Use when a RAG system answers wrong or vaguely, when an index is being designed or reindexed, or when someone proposes a prompt change to fix what is really a retrieval miss. Not for prompt or output-quality work once the right passage is already in context, not for agent memory design, and not for choosing a vector database.

Add to TypingMind

Visão geral

Publicado pornahid-sparktales
Repositórioagent-dispatcher
Nome da habilidaderetrieval-rag
Estrelas
58
Forks
5
Arquivos incluídos
1
LicençaMIT
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    As habilidades de IA são escritas em Markdown simples, não em código específico de um provedor. Por isso, funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • Arquivos incluídos: 1

    Scripts, templates e referências que o modelo pode ler enquanto trabalha. Os arquivos são somente para leitura e nunca são executados.

  • Código aberto

    Publicada por nahid-sparktales no GitHub. Leia os arquivos da habilidade antes de instalá-la.

Instalação

Instale a habilidade de IA Retrieval Rag no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL abaixo, que aponta para a pasta da habilidade, e confirme.
    https://github.com/nahid-sparktales/agent-dispatcher/tree/main/skills/ai/retrieval-rag
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Adicionar habilidade → Via URL do GitHub. Depois, cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nahid-sparktales/agent-dispatcher.git /tmp/agent-dispatcher
mkdir -p .claude/skills
cp -r /tmp/agent-dispatcher/skills/ai/retrieval-rag .claude/skills/retrieval-rag
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Retrieval Rag em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Retrieval Rag automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Retrieval Rag não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

Retrieval for RAG

Most "the model hallucinated" reports are retrieval failures wearing a generation costume. The gold passage was never in the context window, and no prompt edit can fix that. The first job is always to find out which half is broken.

When this fires

A system retrieves documents and feeds them to a model, and the answers are wrong, thin, or unsourced — or an index is being built or rebuilt. It does not fire when the correct passage is demonstrably in context and the model still answers badly; that is a generation problem.

Procedure

  1. Split the failure before fixing anything. Take 10 real failing questions. For each, check whether the passage that answers it appears in the retrieved set at all. Retrieved and answered wrong is a generation problem; never retrieved is a retrieval problem. Do not proceed on a guess — this one check redirects most of the work.
  2. Build the evaluation set before touching the index. 30–50 real questions, each labelled with the id(s) of the passage that answers it. Get them from real logs where possible. Without this set every later change is a reshuffle you cannot tell from an improvement.
  3. Chunk on the document's own structure — headings, sections, list items, function or code blocks — wherever structure exists. Fall back to fixed-size windows only for unstructured prose, with enough overlap that a sentence is not cut in half.
  4. Make each chunk self-describing. Prepend the document title and heading path to the text that gets embedded. A chunk retrieved alone must still say what it is about; "it depends on the previous section" is invisible to the retriever and to the model.
  5. Store the metadata you will need at query time: stable chunk id, source document and URI, heading path, position, timestamp, and any tenant or permission key. You cannot filter on what you did not index, and adding a field later means a reindex.
  6. Pin one embedding model and record it with the index — name, version, dimension, and whether vectors are normalized. Queries and documents must be embedded by the same model, with the same query/document prefix convention if that model asks for one. Changing the model invalidates every stored vector: that is a reindex, not a config tweak.
  7. Add lexical search next to the vector search. Embeddings miss exact tokens — error codes, identifiers, rare product names, negation. Run a keyword index (BM25 or the database's own full-text search) over the same chunks.
  8. Fuse the two result lists by rank, not by raw score. Scores from a vector index and a keyword index are not on a common scale. Reciprocal rank fusion needs no tuned weights and is the correct default; introduce weights only after measuring that fusion alone is not enough.
  9. Retrieve wide, then rerank narrow. Pass roughly the top 50 fused results through a reranking model (a cross-encoder scores query and passage together, unlike the bi-encoder that built the index) and keep only the handful the generator sees. After hybrid search this is usually the largest single gain left.
  10. Filter by permission at query time, as part of the search, not afterwards and never by asking the model to stay quiet about what it read. A chunk the requester may not read must not enter the prompt. If the index has no tenant or permission key, stop and raise it — that is a data boundary, not a tuning detail.
  11. Measure retrieval on its own, generator switched off: recall@k (is the labelled passage anywhere in the top k) at the exact k you will pass to the model, plus MRR or nDCG for ordering. Record the number before and after each change, on the same query set.
  12. Then measure generation with retrieval held fixed: is every claim supported by a retrieved passage, do the citations point at the passage that actually carries the claim, and is the answer right. Changing both layers in one run tells you nothing about either.
  13. Decide what happens when nothing is relevant. Below a score threshold, return "not found" rather than the nearest chunk. A confident answer over irrelevant context is the dominant hallucination source in RAG.
  14. Re-run the whole set after every change to chunking, embedding, fusion or reranking. These interact: a chunking change moves recall, and a reranker tuned against the old chunks may not survive it.

Checklist

  • Failing questions classified as retrieval miss or generation miss, with evidence
  • Labelled query set exists, and predates the changes being measured
  • Chunks carry their heading path and a stable id
  • Embedding model, version and dimension recorded alongside the index
  • Lexical search present and fused with vector search by rank
  • Reranking applied between wide retrieval and the generator's k
  • Permission or tenant filtering happens inside the query
  • recall@k measured at the real k, before and after, on the same set
  • Generation measured separately, with retrieval frozen
  • A no-answer path exists and was exercised

Failure handling

  • Gold passage never appears at any k — the problem is chunking, the embedding model, or missing content. Prompt edits and reranking cannot recover a passage retrieval never returned.
  • Recall is high but answers are still wrong — stop tuning retrieval. The remaining problem is the prompt, the context ordering, or the model.
  • Improvement shows only on hand-picked queries — that is not evidence. Report the full-set delta or report nothing.
  • Reindexing is required — say so plainly, with the cost and the downtime, and ask before starting one on a live index. Dropping or overwriting a production index is destructive: propose it, do not perform it unprompted.
  • The corpus changed under you — an eval run against a different snapshot is not comparable. Record the corpus version with every number.

Evidence to report

The query set size and where the questions came from; recall@k and MRR or nDCG before and after, at the k actually used, with the embedding model, reranker, fusion method and corpus snapshot named; the queries that still fail and what is missing for each; and, when generation was measured, that it was measured with retrieval frozen. "Retrieval improved" without a number and a query set is an impression, not a result.

Arquivos incluídos

O modelo lê esses arquivos sob demanda enquanto a habilidade está carregada. Eles são disponibilizados para leitura e nunca são executados.

Perguntas frequentes

O que a habilidade de IA Retrieval Rag faz?

Build and fix retrieval that actually returns the right passage — structure-aware chunking, one pinned embedding model, lexical plus vector search fused, reranking, and a recall measurement that is run separately from the generator. Use when a RAG system answers wrong or vaguely, when an index is being designed or reindexed, or when someone proposes a prompt change to fix what is really a retrieval miss. Not for prompt or output-quality work once the right passage is already in context, not for agent memory design, and not for choosing a vector database.

Por que usar Retrieval Rag no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. A habilidade Retrieval Rag é escrita em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. No TypingMind, você usa suas próprias chaves de API e paga diretamente aos provedores, em vez de pagar uma assinatura por licença de usuário. Suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Retrieval Rag no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/nahid-sparktales/agent-dispatcher/tree/main/skills/ai/retrieval-rag. O TypingMind lê o arquivo SKILL.md, reúne os arquivos da habilidade e a instala para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Retrieval Rag?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Retrieval Rag?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Retrieval Rag com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Retrieval Rag é gratuita?

Sim. A habilidade é publicada no GitHub por nahid-sparktales sob a licença MIT. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, templates ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas que ele pode acionar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA dá ao modelo o conhecimento e as orientações de que ele precisa: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇