Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core/Hosted]: search feedback #96

Open
louis030195 opened this issue May 14, 2023 · 1 comment
Open

[Core/Hosted]: search feedback #96

louis030195 opened this issue May 14, 2023 · 1 comment

Comments

@louis030195
Copy link
Contributor

louis030195 commented May 14, 2023

Feature request

ChatGPT like user feedback to open opportunities to improve user experience

Motivation

  • interpretability over user happiness as statistics, visualisation in the dashboard
  • eventual fine-tuning or reranking

Your contribution

image

I'm imagining a middleware that save search queries and a new end point that accept feedback on search result with the ID of the result

from typing import Callable

import uuid

from fastapi import Request
from fastapi.responses import JSONResponse

from embedbase.database.base import VectorDatabase
from embedbase.embedding.base import Embedder


async def save_search(
    request: Request, call_next: Callable, db: VectorDatabase, embedder: Embedder
):
    """
    Upon search request, save the request to a database.
    """
    # todo overlap with add on "search" dataset
    if request.method != "POST" or "/v1/search" not in request.url.path:
        return await call_next(request)

    request_body = await request.json()
    new_id = str(uuid.uuid4())
    request_body["id"] = new_id
    response = await db.save("search", request_body)
    return await call_next(request)

(almost) pseudo code for feedback endpoint:

app = (
    get_app()
    .use_embedder(...)
    .use_db(...)
    .run()
)
# An endpoint that let you rate search results
@app.post("/feedback")
async def human_feedback(req, cb, db, embedder):
    # here would save to a table feedback
    # the request body looks like "searchid: vrevrwrew, feedback: 0 or 1"
    db.save("feedback", req.body)
    return 200
@louis030195 louis030195 changed the title [Hosted]: thumbs up down user feedback on search [Core/Hosted]: thumbs up down user feedback on search May 14, 2023
@ccomkhj
Copy link

ccomkhj commented May 14, 2023

Suggest Two milestones in evaluations on search
(I don't fully know the entire architecture, so I leave coarse pseudo codes. )

  1. Direct Thumbs up/down
    -> Only developers (or who built the dataset) are willing to assess this query result.
    -> Who built the service (i.e. a developer at hexafarms or a student who fed their study materials)
    -> High-quality feedback but the limited amount of feedback (max. ~100 feedback)

  2. Indirect evaluation of search return
    So, we can understand how users think good or bad. (in hexafarms' case: farmers)
    [logic I] if similar query asked, give penalty. [because it means the return value was not good enough.]

if similarity_score(embeding_vector(previous_query), embeding_vector(current_query)) > 0.5 and abs(previous_query.time - current_query.time) < 60*5:
   dataset(current_query).score *= 0.9  # penalty ratio

[logic II] if queries are asked many times, but not in shot-term.

def __call__(dataset):
   dataset.score *= 1.001 # adding score

@louis030195 louis030195 changed the title [Core/Hosted]: thumbs up down user feedback on search [Core/Hosted]: search feedback May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants