korvus icon indicating copy to clipboard operation
korvus copied to clipboard

6 rows with limit 6 and 0 rows with limit 5

Open ygmarchi opened this issue 10 months ago • 0 comments

Hello,

I'm facing the weird situation that this query generated by korvus returns 6 rows with limit 6 and 0 rows with limit 5.

with "pipeline" ("schema") as (
select
    "schema"
from
    "ipsilon"."pipelines"
where
    "name" = 'intfloat/multilingual-e5-base') ,
"text_embedding" ("embedding") as (
select
    pgml.embed(transformer => (
    select
        schema #>> '{text,semantic_search,model}'
    from
        pipeline),
    text => 'Come posso chiedere un rimborso spese?',
    kwargs => '{"prompt": "Represent this sentence for searching relevant passages: "}') as "embedding")
select * from (    
select
        1 as score,
        "documents"."id",
        "chunks"."chunk",
        "documents"."document"
    from
        "ipsilon_intfloat/multilingual-e5-base"."text_embeddings" as "embeddings"
    inner join "ipsilon_intfloat/multilingual-e5-base"."text_chunks" as "chunks" on
        "chunks"."id" = "embeddings"."chunk_id"
    inner join "ipsilon"."documents" as "documents" on
        "documents"."id" = "chunks"."document_id"
    inner join "ipsilon_intfloat/multilingual-e5-base"."text_tsvectors" as "tsvectors" on
        "tsvectors"."chunk_id" = "embeddings"."chunk_id"
    where
        tsvectors.ts @@ plainto_tsquery((
        select
            oid
        from
            pg_ts_config
        where
            cfgname = (
            select
                schema #>> '{text,full_text_search,configuration}'
            from
                pipeline)),
        'rimborso spese')
    order by
        embeddings.embedding <=> (
        select
            embedding
        from
            "text_embedding")::vector asc
) s            
limit 6```

ygmarchi avatar Mar 10 '25 11:03 ygmarchi