|
|
@@ -72,6 +72,79 @@ query from the `cohere-embeddings` index sorted by their proximity to the query:
|
|
|
|
|
|
// end::cohere[]
|
|
|
|
|
|
+// tag::hugging-face[]
|
|
|
+
|
|
|
+[source,console]
|
|
|
+--------------------------------------------------
|
|
|
+GET hugging-face-embeddings/_search
|
|
|
+{
|
|
|
+ "knn": {
|
|
|
+ "field": "content_embedding",
|
|
|
+ "query_vector_builder": {
|
|
|
+ "text_embedding": {
|
|
|
+ "model_id": "hugging_face_embeddings",
|
|
|
+ "model_text": "What's margin of error?"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "k": 10,
|
|
|
+ "num_candidates": 100
|
|
|
+ },
|
|
|
+ "_source": [
|
|
|
+ "id",
|
|
|
+ "content"
|
|
|
+ ]
|
|
|
+}
|
|
|
+--------------------------------------------------
|
|
|
+// TEST[skip:TBD]
|
|
|
+
|
|
|
+As a result, you receive the top 10 documents that are closest in meaning to the
|
|
|
+query from the `hugging-face-embeddings` index sorted by their proximity to the query:
|
|
|
+
|
|
|
+[source,consol-result]
|
|
|
+--------------------------------------------------
|
|
|
+"hits": [
|
|
|
+ {
|
|
|
+ "_index": "hugging-face-embeddings",
|
|
|
+ "_id": "ljEfo44BiUQvMpPgT20E",
|
|
|
+ "_score": 0.8522128,
|
|
|
+ "_source": {
|
|
|
+ "id": 7960255,
|
|
|
+ "content": "The margin of error can be defined by either of the following equations. Margin of error = Critical value x Standard deviation of the statistic. Margin of error = Critical value x Standard error of the statistic. If you know the standard deviation of the statistic, use the first equation to compute the margin of error. Otherwise, use the second equation. Previously, we described how to compute the standard deviation and standard error."
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "_index": "hugging-face-embeddings",
|
|
|
+ "_id": "lzEfo44BiUQvMpPgT20E",
|
|
|
+ "_score": 0.7865497,
|
|
|
+ "_source": {
|
|
|
+ "id": 7960259,
|
|
|
+ "content": "1 y ou are told only the size of the sample and are asked to provide the margin of error for percentages which are not (yet) known. 2 This is typically the case when you are computing the margin of error for a survey which is going to be conducted in the future."
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "_index": "hugging-face-embeddings1",
|
|
|
+ "_id": "DjEfo44BiUQvMpPgT20E",
|
|
|
+ "_score": 0.6229427,
|
|
|
+ "_source": {
|
|
|
+ "id": 2166183,
|
|
|
+ "content": "1. In general, the point at which gains equal losses. 2. In options, the market price that a stock must reach for option buyers to avoid a loss if they exercise. For a call, it is the strike price plus the premium paid. For a put, it is the strike price minus the premium paid."
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "_index": "hugging-face-embeddings1",
|
|
|
+ "_id": "VzEfo44BiUQvMpPgT20E",
|
|
|
+ "_score": 0.6034223,
|
|
|
+ "_source": {
|
|
|
+ "id": 2173417,
|
|
|
+ "content": "How do you find the area of a circle? Can you measure the area of a circle and use that to find a value for Pi?"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (...)
|
|
|
+ ]
|
|
|
+--------------------------------------------------
|
|
|
+// NOTCONSOLE
|
|
|
+
|
|
|
+// end::hugging-face[]
|
|
|
|
|
|
// tag::openai[]
|
|
|
|