feedback-loops
БесплатноБез исполняемых скриптовНе проверенUser feedback signals for RAG improvement: thumbs up/down, click-through, dwell time, explicit ratings. Implicit vs explicit signals, logging schema, feedback…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Feedback Loops for RAG
Signals
Explicit
| Signal | Latency | Density | Reliability |
|---|---|---|---|
| Thumbs up/down | Immediate | Low (< 5% response rate) | Medium — noisy |
| Star rating (1-5) | Immediate | Very low | Higher, but biased toward extremes |
| Free-text feedback | Delayed | Lowest | Highest — but hard to parse |
| Per-citation accept/reject | Immediate | Low | High — directly actionable |
Implicit
| Signal | Captures | Caveat |
|---|---|---|
| Click-through on citation | Perceived relevance | Confirms source seen, not correctness |
| Dwell time on cited doc | Actual engagement | Needs session tracking |
| Copy text | High intent | Only partial |
| Regenerate click | Answer failure | Ambiguous — could be style not content |
| Next-turn "no, I meant..." | Answer failure | Parse NLU |
| Session abandonment | Frustration | Noisy — could be scheduled meeting |
| Scroll depth on answer | Read-through | Weak signal |
Always log both. Implicit is dense; explicit is reliable. Combine.
Logging Schema
from pydantic import BaseModel
from datetime import datetime
from typing import Literal
from uuid import UUID
class RagEvent(BaseModel):
event_id: UUID
session_id: UUID
user_id: str | None
ts: datetime
# Query context
query: str
rewritten_query: str | None
classifier_path: str
# Retrieval
retriever_variant: str # for A/B
retrieved_ids: list[str] # chunk IDs with rank
retrieval_scores: list[float]
# Generation
answer_id: UUID
model: str
tokens_in: int
tokens_out: int
latency_ms: int
# Citations emitted by answer
cited_ids: list[str]
class FeedbackEvent(BaseModel):
event_id: UUID
answer_id: UUID # FK to RagEvent
kind: Literal["thumbs", "rating", "citation_click", "citation_accept",
"citation_reject", "regenerate", "copy", "dwell", "free_text"]
value: float | str | None # 1/-1 for thumbs, 1-5 for rating, seconds for dwell
chunk_id: str | None # for citation-level feedback
ts: datetime
Store in an append-only table (Postgres, BigQuery, Clickhouse). Join on answer_id downstream. Do not mutate rows — feedback events are facts.
Integration: Langfuse
from langfuse import Langfuse
from langfuse.decorators import observe, langfuse_context
langfuse = Langfuse()
@observe()
def answer(q: str, session_id: str):
langfuse_context.update_current_trace(session_id=session_id, input=q)
docs = retriever.invoke(q)
langfuse_context.update_current_observation(
metadata={"retrieved": [d.metadata["id"] for d in docs]}
)
ans = llm.invoke(build_prompt(q, docs))
langfuse_context.update_current_trace(output=ans.content)
return ans.content, langfuse_context.get_current_trace_id()
# Later, from the UI:
def record_thumbs(trace_id: str, value: int):
langfuse.score(trace_id=trace_id, name="thumbs", value=value, data_type="BOOLEAN")
Integration: LangSmith
from langsmith import Client
client = Client()
def record_feedback(run_id: str, kind: str, value):
client.create_feedback(run_id, key=kind, score=value if kind == "thumbs" else None,
value=str(value))
From Signal to Hard Negatives
Low-rated answers plus the chunks that were retrieved but not helpful are hard-negative training material for the embedding model.
import polars as pl
def build_hard_negatives(days: int = 30):
df = pl.read_database("SELECT * FROM rag_events WHERE ts > now() - INTERVAL '30 days'")
fb = pl.read_database("SELECT * FROM feedback_events WHERE kind='thumbs'")
joined = df.join(fb, on="answer_id").filter(pl.col("value") == -1)
# Explicit negative signal: query + retrieved chunks that did not lead to a useful answer.
pairs = []
for row in joined.iter_rows(named=True):
for cid in row["retrieved_ids"][:5]:
pairs.append({"query": row["query"], "negative_id": cid})
return pairs
Pair hard negatives with user-accepted positive citations (citation_accept events) to build triples:
def triples():
# (query, positive_chunk, negative_chunk)
...
Embedding Fine-Tuning (Sentence-Transformers)
from sentence_transformers import SentenceTransformer, InputExample, losses
from torch.utils.data import DataLoader
model = SentenceTransformer("BAAI/bge-base-en-v1.5")
examples = [
InputExample(texts=[row["query"], row["positive_text"], row["negative_text"]])
for row in triples_df.iter_rows(named=True)
]
loader = DataLoader(examples, shuffle=True, batch_size=16)
loss = losses.TripletLoss(model=model, triplet_margin=0.3)
model.fit([(loader, loss)], epochs=3, warmup_steps=100)
model.save("models/bge-ft-v2")
Re-embed the corpus with the fine-tuned model (blue-green index swap). Measure retrieval P@5 and MRR on a held-out eval set before prom
Установить feedback-loops в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditFAQ
Что делает скилл feedback-loops?
User feedback signals for RAG improvement: thumbs up/down, click-through, dwell time, explicit ratings. Implicit vs explicit signals, logging schema, feedback -> retraining pipelines (embedding fine-tuning with hard negatives, reranker fine-tuning from CTR), A/B testing RAG variants, Langfuse/LangSmith feedback APIs, feature stores for online learning. USE WHEN: user mentions "user feedback", "thumbs up down", "CTR", "dwell time", "RAG evaluation feedback", "hard negatives", "reranker fine-tune", "A/B test RAG" DO NOT USE FOR: offline eval metrics - use `rag-evaluation`; retriever algorithms - use `advanced-retrieval`; observability as such - use `rag-observability`
Как установить скилл feedback-loops?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл feedback-loops запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic