Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -68,7 +68,7 @@ chunks_table = "your_chunks_table" # columns: chunk_id, chunk_txt
|
|
| 68 |
QUERY = "What is the best-known landmark in Paris?"
|
| 69 |
|
| 70 |
query = f"""
|
| 71 |
-
SELECT chunk_id, chunk_txt,
|
| 72 |
FROM mldb.ONNXEmbeddings(
|
| 73 |
ON (SELECT chunk_id, chunk_txt, '{QUERY}' || '</s></s>' || chunk_txt AS txt
|
| 74 |
FROM {chunks_table}) AS InputTable
|
|
@@ -86,7 +86,7 @@ result = tdml.DataFrame.from_query(query).to_pandas().sort_values("relevance_sco
|
|
| 86 |
|
| 87 |
`relevance_score` is the model's raw logit -- sorting by it directly already gives the correct
|
| 88 |
ranking, since `sigmoid` is monotonic. If you need an actual `[0, 1]` probability rather than
|
| 89 |
-
just a ranking, compute it in SQL instead of Python: `1 / (1 + EXP(-
|
| 90 |
|
| 91 |
## Combining with vector search for two-stage retrieval
|
| 92 |
|
|
@@ -103,9 +103,9 @@ CREATE VOLATILE TABLE shortlist AS (
|
|
| 103 |
ON chunk_embeddings AS ReferenceTable DIMENSION
|
| 104 |
USING
|
| 105 |
TargetIDColumn('query_id')
|
| 106 |
-
TargetFeatureColumns('[
|
| 107 |
RefIDColumn('chunk_id')
|
| 108 |
-
RefFeatureColumns('[
|
| 109 |
DistanceMeasure('cosine')
|
| 110 |
TopK(20)
|
| 111 |
) AS dt
|
|
|
|
| 68 |
QUERY = "What is the best-known landmark in Paris?"
|
| 69 |
|
| 70 |
query = f"""
|
| 71 |
+
SELECT chunk_id, chunk_txt, emb_0 AS relevance_score
|
| 72 |
FROM mldb.ONNXEmbeddings(
|
| 73 |
ON (SELECT chunk_id, chunk_txt, '{QUERY}' || '</s></s>' || chunk_txt AS txt
|
| 74 |
FROM {chunks_table}) AS InputTable
|
|
|
|
| 86 |
|
| 87 |
`relevance_score` is the model's raw logit -- sorting by it directly already gives the correct
|
| 88 |
ranking, since `sigmoid` is monotonic. If you need an actual `[0, 1]` probability rather than
|
| 89 |
+
just a ranking, compute it in SQL instead of Python: `1 / (1 + EXP(-emb_0))`.
|
| 90 |
|
| 91 |
## Combining with vector search for two-stage retrieval
|
| 92 |
|
|
|
|
| 103 |
ON chunk_embeddings AS ReferenceTable DIMENSION
|
| 104 |
USING
|
| 105 |
TargetIDColumn('query_id')
|
| 106 |
+
TargetFeatureColumns('[emb_0:emb_383]')
|
| 107 |
RefIDColumn('chunk_id')
|
| 108 |
+
RefFeatureColumns('[emb_0:emb_383]')
|
| 109 |
DistanceMeasure('cosine')
|
| 110 |
TopK(20)
|
| 111 |
) AS dt
|