-
Notifications
You must be signed in to change notification settings - Fork 2
/
les-mis-nlp-search
82 lines (75 loc) · 1.67 KB
/
les-mis-nlp-search
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
PUT les-miserable-embedded
{
"mappings": {
"properties": {
"ml": {
"properties": {
"inference": {
"properties": {
"model_id": {
"type": "keyword"
},
"predicted_value": {
"type": "dense_vector",
"dims": 384,
"index": true,
"similarity": "l2_norm"
}
}
}
}
}
}
}
}
# Useful setup if required
PUT _ingest/pipeline/embed-les-mis
{
"description" : "embed pipeline",
"processors" : [
{
"inference" : {
"model_id" : "sentence-transformers__msmarco-minilm-l-12-v3",
"field_map": {
"paragraph": "text_field"
}
}
},
{
"set" : {
"field" : "timestamp",
"value" : "{{_ingest.timestamp}}"
}
}
]
}
POST _reindex
{
"source": {
"index": "les-mis"
},
"dest": {
"index": "les-miserable-embedded",
"pipeline": "embed-les-mis"
}
}
POST _ml/trained_models/sentence-transformers__msmarco-minilm-l-12-v3/deployment/_infer
{
"docs": [{"text_field": "What was Jean Valjean prisoner number?"}]
}
GET les-miserable-embedded/_search?size=1
GET les-miserable-embedded
POST les-miserable-embedded/_knn_search
{
"_source": ["paragraph", "line"],
"knn": {
"field": "ml.inference.predicted_value",
"k": 5,
"num_candidates": 10,
"query_vector": # Put query vector here
}
}
POST _ml/trained_models/sentence-transformers__msmarco-minilm-l-12-v3/deployment/_infer
{
"docs": [{"text_field": "How much could Jean Valjean sell the candlesticks?"}]
}