Changes between Version 3 and Version 4 of AdvancedTopics


Ignore:
Timestamp:
06/15/26 00:24:15 (29 hours ago)
Author:
231141
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedTopics

    v3 v4  
    280280}}}
    281281
     282= Worker Recommendation for Task Requests =
     283
     284Besides recommending task requests to workers, the system also supports recommending suitable workers for a specific task request.
     285
     286The function compares the embedding of the selected task request with the stored worker profile embeddings and ranks the workers according to their vector similarity. Workers who have already submitted an offer for the given task request are excluded from the results.
     287
     288{{{#!sql
     289CREATE OR REPLACE FUNCTION
     290recommend_workers_for_task_request
     291(
     292    p_task_request_id BIGINT,
     293    p_limit INT DEFAULT 20
     294)
     295RETURNS TABLE
     296(
     297    worker_id BIGINT,
     298    distance DOUBLE PRECISION,
     299    recommendation_type TEXT
     300)
     301LANGUAGE plpgsql
     302AS
     303$$
     304BEGIN
     305    RETURN QUERY
     306    SELECT
     307        wrp.worker_id::BIGINT,
     308        tre.embedding
     309        <=>
     310        wrp.preference_embedding
     311        AS distance,
     312        'PERSONALIZED'::TEXT
     313    FROM task_request_embeddings tre
     314    JOIN worker_recommendation_profiles wrp
     315        ON wrp.preference_embedding IS NOT NULL
     316    WHERE
     317        tre.task_request_id = p_task_request_id
     318        AND wrp.worker_id NOT IN
     319        (
     320            SELECT
     321                o.worker_id
     322            FROM Offer o
     323            WHERE
     324                o.task_request_id = p_task_request_id
     325        )
     326    ORDER BY
     327        distance ASC
     328    LIMIT
     329        p_limit;
     330END;
     331$$;
     332}}}
     333
     334{{{#!sql
     335SELECT *
     336FROM recommend_workers_for_task_request(150, 20);
     337}}}
     338
     339The query returns the 20 workers whose previous completed tasks are the most semantically similar to the selected task request.