Notebooks
W
Weaviate
Similarity Search Transformers

Similarity Search Transformers

vector-searchvector-databaseretrieval-augmented-generationllm-frameworksweaviate-featuresfunction-callingtransformersweaviate-recipesmodel-providersPythongenerative-ai

Similarity search with Weaviate's text2vec-transformers module

Dependencies

[ ]

Connect to Weaviate

text2vec-transformers is only available through Weaviate open-source via Docker or Kubernetes. This integration is not available for Weaviate Cloud (WCD) serverless instances, as it requires spinning up a container with the Hugging Face model.

Here are options to select your desired model:

  1. Pre-built transformers model containers

    Example docker-compose.yml

    ---
    services:
    weaviate:
        command:
        - --host
        - 0.0.0.0
        - --port
        - '8080'
        - --scheme
        - http
        image: cr.weaviate.io/semitechnologies/weaviate:1.30.0
        ports:
        - 8080:8080
        - 50051:50051
        restart: on-failure:0
        environment:
        TRANSFORMERS_INFERENCE_API: 'http://t2v-transformers:8080'
        QUERY_DEFAULTS_LIMIT: 25
        AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
        PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
        DEFAULT_VECTORIZER_MODULE: 'text2vec-transformers'
        ENABLE_MODULES: 'text2vec-transformers'
        CLUSTER_HOSTNAME: 'node1'
    t2v-transformers:
        image: cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-multi-qa-MiniLM-L6-cos-v1
        environment:
        ENABLE_CUDA: '0'
    ...
    

    and start up Docker container with

    docker-compose up -d
    
  2. Any model from Hugging Face Model Hub

  3. Use any private or local PyTorch or Tensorflow transformer model

[ ]
[3]
{'text2vec-transformers': {'model': {'_name_or_path': './models/model',
,   'add_cross_attention': False,
,   'architectures': ['BertModel'],
,   'attention_probs_dropout_prob': 0.1,
,   'bad_words_ids': None,
,   'begin_suppress_tokens': None,
,   'bos_token_id': None,
,   'chunk_size_feed_forward': 0,
,   'classifier_dropout': None,
,   'cross_attention_hidden_size': None,
,   'decoder_start_token_id': None,
,   'diversity_penalty': 0,
,   'do_sample': False,
,   'early_stopping': False,
,   'encoder_no_repeat_ngram_size': 0,
,   'eos_token_id': None,
,   'exponential_decay_length_penalty': None,
,   'finetuning_task': None,
,   'forced_bos_token_id': None,
,   'forced_eos_token_id': None,
,   'gradient_checkpointing': False,
,   'hidden_act': 'gelu',
,   'hidden_dropout_prob': 0.1,
,   'hidden_size': 384,
,   'id2label': {'0': 'LABEL_0', '1': 'LABEL_1'},
,   'initializer_range': 0.02,
,   'intermediate_size': 1536,
,   'is_decoder': False,
,   'is_encoder_decoder': False,
,   'label2id': {'LABEL_0': 0, 'LABEL_1': 1},
,   'layer_norm_eps': 1e-12,
,   'length_penalty': 1,
,   'max_length': 20,
,   'max_position_embeddings': 512,
,   'min_length': 0,
,   'model_type': 'bert',
,   'no_repeat_ngram_size': 0,
,   'num_attention_heads': 12,
,   'num_beam_groups': 1,
,   'num_beams': 1,
,   'num_hidden_layers': 6,
,   'num_return_sequences': 1,
,   'output_attentions': False,
,   'output_hidden_states': False,
,   'output_scores': False,
,   'pad_token_id': 0,
,   'position_embedding_type': 'absolute',
,   'prefix': None,
,   'problem_type': None,
,   'pruned_heads': {},
,   'remove_invalid_values': False,
,   'repetition_penalty': 1,
,   'return_dict': True,
,   'return_dict_in_generate': False,
,   'sep_token_id': None,
,   'suppress_tokens': None,
,   'task_specific_params': None,
,   'temperature': 1,
,   'tf_legacy_loss': False,
,   'tie_encoder_decoder': False,
,   'tie_word_embeddings': True,
,   'tokenizer_class': None,
,   'top_k': 50,
,   'top_p': 1,
,   'torch_dtype': 'float32',
,   'torchscript': False,
,   'transformers_version': '4.53.1',
,   'type_vocab_size': 2,
,   'typical_p': 1,
,   'use_bfloat16': False,
,   'use_cache': True,
,   'vocab_size': 30522},
,  'model_path': './models/model'}}

Create a collection

Collection stores your data and vector embeddings.

[4]
Successfully created collection: JeopardyQuestion.

Import the Data

[5]
Adding {'Category': 'SCIENCE', 'Question': 'This organ removes excess glucose from the blood & stores it as glycogen', 'Answer': 'Liver'}
Adding {'Category': 'ANIMALS', 'Question': "It's the only living mammal in the order Proboseidea", 'Answer': 'Elephant'}
Adding {'Category': 'ANIMALS', 'Question': 'The gavial looks very much like a crocodile except for this bodily feature', 'Answer': 'the nose or snout'}
Adding {'Category': 'ANIMALS', 'Question': 'Weighing around a ton, the eland is the largest species of this animal in Africa', 'Answer': 'Antelope'}
Adding {'Category': 'ANIMALS', 'Question': 'Heaviest of all poisonous snakes is this North American rattlesnake', 'Answer': 'the diamondback rattler'}
Adding {'Category': 'SCIENCE', 'Question': "2000 news: the Gunnison sage grouse isn't just another northern sage grouse, but a new one of this classification", 'Answer': 'species'}
Adding {'Category': 'SCIENCE', 'Question': 'A metal that is "ductile" can be pulled into this while cold & under pressure', 'Answer': 'wire'}
Adding {'Category': 'SCIENCE', 'Question': 'In 1953 Watson & Crick built a model of the molecular structure of this, the gene-carrying substance', 'Answer': 'DNA'}
Adding {'Category': 'SCIENCE', 'Question': 'Changes in the tropospheric layer of this are what gives us weather', 'Answer': 'the atmosphere'}
Adding {'Category': 'SCIENCE', 'Question': 'In 70-degree air, a plane traveling at about 1,130 feet per second breaks it', 'Answer': 'Sound barrier'}
/Users/leonie/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
Import Complete
[6]
AggregateReturn(properties={}, total_count=10)

Query Weaviate: Similarity Search (Text objects)

Similarity search options for text objects in Weaviate:

  1. near_text

  2. near_object

  3. near_vector

nearText Example

Find a JeopardyQuestion about "animals in movies". Limit it to only 4 responses.

[7]
ID: 8a00fbd2-45fa-48f2-8854-0ed373f03613
Data: {
  "question": "Weighing around a ton, the eland is the largest species of this animal in Africa",
  "answer": "Antelope",
  "category": "ANIMALS"
} 

ID: 7727cb1f-a08d-40b0-9da6-e4746f3337fa
Data: {
  "question": "The gavial looks very much like a crocodile except for this bodily feature",
  "answer": "the nose or snout",
  "category": "ANIMALS"
} 

ID: 3e1b444f-dbb0-4108-8c6e-eb2d6a7ceff5
Data: {
  "question": "It's the only living mammal in the order Proboseidea",
  "answer": "Elephant",
  "category": "ANIMALS"
} 

ID: aac57491-eced-4033-866c-a0ca20f20a35
Data: {
  "question": "Heaviest of all poisonous snakes is this North American rattlesnake",
  "answer": "the diamondback rattler",
  "category": "ANIMALS"
} 

Return vector embeddings.

[8]
ID: 8a00fbd2-45fa-48f2-8854-0ed373f03613
Data: {
  "question": "Weighing around a ton, the eland is the largest species of this animal in Africa",
  "answer": "Antelope",
  "category": "ANIMALS"
}
Vector: {'default': [-0.11791916936635971, 0.6624627113342285, 0.18456493318080902, -0.08122072368860245, -0.49247342348098755, -0.5737257599830627, -0.15386492013931274, 0.3993226885795593, -0.3364018201828003, 0.9105186462402344, -0.40116187930107117, -0.44404107332229614, -0.23901110887527466, 0.10679106414318085, -0.13704107701778412, -0.09618320316076279, 0.1664130538702011, -0.04804283007979393, 0.01201174221932888, 0.01210771780461073, 0.19907936453819275, 0.038498226553201675, 0.06976787745952606, 0.12092171609401703, -0.6761063933372498, -0.41834601759910583, -0.5966598391532898, 0.520249605178833, 0.2846285104751587, -0.630042552947998, -0.0729237049818039, 0.3715086281299591, 0.6463991403579712, 0.15955376625061035, -0.4426628351211548, -0.16930973529815674, -0.33322933316230774, -0.4225294589996338, -0.01677296683192253, 0.21759285032749176, 0.43390098214149475, 0.41548049449920654, 0.18705947697162628, -0.3398680090904236, -0.32404664158821106, -0.16378334164619446, 0.01133645512163639, 0.12602530419826508, 0.05365283042192459, -0.1808023452758789, 0.30139195919036865, -0.40965282917022705, -0.35266444087028503, 0.5605552792549133, -0.43147242069244385, -0.6106421947479248, -0.030906250700354576, -0.17869560420513153, 0.007218694780021906, -0.525120735168457, 0.6845846772193909, 0.5516973733901978, 0.16182833909988403, 0.4166735112667084, -0.24419410526752472, -0.07044435292482376, 0.06510577350854874, -0.401894211769104, -0.20082862675189972, -0.10275232046842575, 0.2857207655906677, -0.5123637914657593, -0.07064349949359894, 0.5243058800697327, -0.16593165695667267, -0.01819278672337532, -0.1468813568353653, -0.3157561123371124, 0.08962499350309372, 0.49027153849601746, -0.38907918334007263, -0.30011099576950073, -0.20696811378002167, -0.289399117231369, 0.35618725419044495, -0.35704028606414795, 0.2358573079109192, 0.26122841238975525, -0.403455913066864, -0.15313224494457245, 0.3166418969631195, 0.30268269777297974, 0.3246784508228302, 0.4295351505279541, -0.23291675746440887, -0.1392548680305481, -0.024218687787652016, 0.0011394501198083162, -0.25968557596206665, -0.3496408760547638, 0.20006991922855377, -0.12593001127243042, 0.20777013897895813, 0.34672680497169495, 0.034471962600946426, -0.15227888524532318, 0.11998877674341202, -0.3449041247367859, -0.14899003505706787, 0.07780108600854874, -0.33417659997940063, 0.21656082570552826, 0.031213166192173958, 0.24189060926437378, -0.06806087493896484, -0.38634759187698364, -0.06998507678508759, -0.09474317729473114, -0.5848513841629028, 0.029707327485084534, 0.04742114245891571, -0.08523109555244446, -0.03075064718723297, -0.04314493015408516, 0.6174675226211548, 0.3521956503391266, -0.004145947750657797, 4.608338087539935e-30, -0.25677937269210815, -0.34712353348731995, 0.06953073292970657, -0.564373254776001, -0.2123403549194336, 0.2240363508462906, -0.06678415089845657, 0.7001165151596069, -0.01876361481845379, 0.0033265971578657627, -0.5467976927757263, 0.22979852557182312, 0.806822657585144, 0.5682721138000488, 0.2162231057882309, -0.2196275293827057, 0.09858541190624237, -0.11223793774843216, 0.023405643180012703, 0.05527119338512421, 0.144112229347229, -0.33243316411972046, 0.08846334367990494, -0.2903418242931366, 0.21501614153385162, -0.5159841179847717, -0.5266076922416687, -0.3010799288749695, -0.15681900084018707, 0.06680656224489212, 0.5001657009124756, -0.5916797518730164, -0.07853871583938599, -0.022812340408563614, -0.4192676246166229, -0.4379350244998932, 0.1858007311820984, -0.17069177329540253, -0.24464301764965057, -0.5749427080154419, 0.39293304085731506, -0.18141460418701172, 0.011661451309919357, 0.2872653305530548, 0.13169395923614502, 0.3932485282421112, 0.2791502773761749, -0.14067432284355164, 0.36209723353385925, -0.015525119379162788, 0.2594517171382904, 0.32182711362838745, 0.24450358748435974, -0.0699441060423851, 0.2542245090007782, 0.5555912852287292, -0.07947006076574326, -0.04171122610569, 0.12832139432430267, 0.1668199598789215, 0.0564657598733902, 0.2666190266609192, 0.5892865657806396, -0.03123721294105053, 0.4511270821094513, -0.08976855129003525, 0.02950647845864296, -0.15482549369335175, -0.038568418473005295, -0.13014255464076996, 0.3012131452560425, -0.09908106178045273, 0.7250388264656067, -0.258294939994812, -0.19357450306415558, 0.238129660487175, -0.003078565699979663, -0.14918476343154907, -0.23197580873966217, 0.10470959544181824, -0.15975113213062286, -0.1216111108660698, 0.5876145958900452, -0.3877735435962677, 0.07314638793468475, -0.4162353575229645, 0.05619063228368759, -0.05134262889623642, 0.20593100786209106, 0.18803396821022034, 0.2051078826189041, 0.005379888229072094, -0.520832359790802, -0.10815778374671936, 0.3728974461555481, -1.639480191254282e-32, -0.014388727955520153, 0.6879569292068481, -0.023399334400892258, 0.29180803894996643, 0.19208301603794098, 0.2782234251499176, 0.17542968690395355, 0.4152323007583618, -0.2900717854499817, -0.02018963359296322, 0.27464938163757324, -0.28582480549812317, 0.6714427471160889, -0.1953628659248352, 0.4844522178173065, -0.2662728428840637, -0.19497358798980713, -0.2578914165496826, 0.26349881291389465, -0.4019322991371155, -0.4004422724246979, -0.32134705781936646, -0.19568121433258057, -0.4321114420890808, -0.028542308136820793, -0.04286639764904976, -0.30987435579299927, 0.013089188374578953, 0.056086763739585876, -0.21442271769046783, 0.13142645359039307, 0.4071253836154938, -0.15156441926956177, -0.0010230147745460272, 0.030989529564976692, -0.171639084815979, 0.25467023253440857, 0.04924606904387474, -0.24475395679473877, 0.0255033690482378, 0.032098639756441116, 0.3213011920452118, -0.15353888273239136, -0.1304798722267151, 0.4977940320968628, -0.11866678297519684, 0.5342469811439514, -0.09336291253566742, 0.3093836307525635, -0.15645051002502441, 0.30592331290245056, 0.19695331156253815, 0.5894031524658203, -0.01560943853110075, 0.8536695837974548, 0.0661432147026062, 0.08605369925498962, 0.0926738753914833, -0.31658297777175903, -0.7021946907043457, -0.09619123488664627, -0.2433594912290573, 0.01339004561305046, 0.007567731197923422, -0.48463258147239685, 0.17191404104232788, 0.0669538751244545, -0.11779911071062088, -0.22787775099277496, 0.0633484348654747, -0.3580511212348938, 0.17504650354385376, 0.28615444898605347, -0.3822547495365143, -0.2674596905708313, 0.2638711631298065, 0.13206133246421814, -0.5787615180015564, -0.1835700273513794, -0.46806347370147705, -0.055146846920251846, -0.2053423672914505, 0.5680749416351318, -0.09469164162874222, -0.3799225986003876, -0.02537551149725914, -0.7395312786102295, 0.14844058454036713, 0.4390243589878082, 0.5004391670227051, -0.5549395084381104, -0.24175509810447693, -0.0252750962972641, -0.07221192866563797, 0.49538499116897583, -2.2754486428616516e-32, 0.4666270315647125, 0.3416624069213867, 0.487565279006958, 0.017370564863085747, 0.10019758343696594, 0.6217346787452698, -0.3466419279575348, 0.3468742370605469, -0.22708530724048615, 0.5825541615486145, 0.13048334419727325, 0.14381952583789825, 0.029251309111714363, 0.5074740648269653, -0.22773781418800354, -0.09985384345054626, -0.13356426358222961, -0.5918748378753662, 0.18480895459651947, -0.07240237295627594, -0.6130449175834656, 0.49724048376083374, -0.1800386756658554, -0.1114930510520935, 0.2062980830669403, -0.23449520766735077, -0.25132301449775696, -0.06776800006628036, -0.12312263250350952, 0.38558265566825867, -0.47825872898101807, -0.023550326004624367, -0.1588314175605774, 0.07603761553764343, -0.03550517559051514, -0.18835817277431488, -0.14028114080429077, 0.052873946726322174, -0.0943349078297615, -0.1558241844177246, 0.46385133266448975, 0.41615211963653564, 0.23910760879516602, 0.003269696142524481, 0.5974693894386292, -0.023148875683546066, 0.010624367743730545, 0.06082809343934059, 0.021088533103466034, -0.4772978127002716, 0.21764954924583435, -0.3665129840373993, -0.108965665102005, 0.022434845566749573, 0.017724838107824326, 0.13079525530338287, -0.3745386004447937, -0.30503568053245544, 0.2565678656101227, 0.4739762544631958, 0.0564856231212616, -0.5692769885063171, 0.2882073223590851, 0.10352561622858047]} 

ID: 7727cb1f-a08d-40b0-9da6-e4746f3337fa
Data: {
  "question": "The gavial looks very much like a crocodile except for this bodily feature",
  "answer": "the nose or snout",
  "category": "ANIMALS"
}
Vector: {'default': [-0.011600219644606113, 0.1409519463777542, 0.3601076006889343, 0.18627692759037018, -0.15938185155391693, -0.3061172366142273, 0.1143486425280571, -0.3593030273914337, -0.017292777076363564, 0.6016177535057068, 0.14370596408843994, -0.6367710828781128, 0.0012541413307189941, 0.5919391512870789, 0.22086165845394135, -0.49081453680992126, 0.3741567134857178, -0.01826254092156887, 0.3237866163253784, -0.027537420392036438, -0.18640555441379547, 0.4087415039539337, 0.06816476583480835, -0.007660408969968557, -0.6984982490539551, -0.30533427000045776, 0.1420808732509613, -0.2072761207818985, -0.11381208151578903, -0.40549927949905396, -0.2735242545604706, 0.04162397235631943, -0.10199136286973953, -0.21349969506263733, -0.036439746618270874, -0.3561907708644867, 0.2036740481853485, 0.35895901918411255, 0.08596378564834595, 0.3203224539756775, -0.3303240239620209, 0.057720065116882324, -0.04199651628732681, -0.010427488014101982, 0.13896137475967407, 0.019751671701669693, -0.4931996464729309, 0.478049099445343, 0.10373511165380478, -0.34436386823654175, -0.19745329022407532, -0.4140446186065674, -0.30103230476379395, -0.27269914746284485, -0.08255115151405334, 0.20762532949447632, -0.42683836817741394, -0.473237007856369, -0.052843403071165085, -0.2558424174785614, 0.2206924706697464, 0.06451132148504257, 0.5739938616752625, 0.5419926643371582, -0.3135889768600464, -0.2717735469341278, 0.03649601340293884, -0.41121506690979004, 0.4943704307079315, -0.29935580492019653, -0.1755850464105606, -0.3644115626811981, -0.20773930847644806, -0.3302184045314789, -0.18913480639457703, -0.1879742592573166, 0.06461934000253677, -0.09238166362047195, 0.07442938536405563, 0.2666204571723938, 0.24352948367595673, 0.6406537890434265, 0.09107881784439087, -0.017067870125174522, 0.2746392488479614, 0.086227647960186, 0.24902276694774628, -0.10828378796577454, -0.6741538643836975, -0.11280273646116257, 0.22102153301239014, 0.07284601032733917, 0.19110970199108124, -0.29741987586021423, -0.16437634825706482, -0.2117866426706314, -0.04180091619491577, -0.15130746364593506, -0.009011107496917248, 0.05380614846944809, -0.2915283143520355, -0.5441418290138245, 0.47468850016593933, 0.1870596706867218, 0.587402880191803, 0.23000843822956085, -0.13591471314430237, -0.19090047478675842, 0.3989238739013672, 0.08309420943260193, 0.0533558689057827, 0.09747801721096039, -0.3086681067943573, 0.1662539541721344, 0.02630499191582203, -0.22838397324085236, -0.5140003561973572, -0.2505471408367157, -0.07733572274446487, 0.15587209165096283, -0.017079517245292664, -0.15988372266292572, 0.04079058766365051, -0.18311329185962677, 0.5955890417098999, 0.0014894773485139012, -0.2477390617132187, 1.843288365705218e-30, -0.024981403723359108, 0.2452777773141861, -0.09018280357122421, -0.4998616874217987, -0.010524044744670391, -0.04766643047332764, 0.19011469185352325, 0.09485967457294464, -0.09403522312641144, 0.5531788468360901, 0.07832906395196915, -0.08098328113555908, -0.24769124388694763, 0.6135484576225281, -0.223290354013443, 0.23163481056690216, -0.1278211623430252, 0.31693387031555176, -0.23633189499378204, -0.05310581624507904, -0.24992619454860687, 0.31789931654930115, 0.31098395586013794, -0.43448731303215027, 0.101526640355587, 0.15102118253707886, -0.37098976969718933, -0.6827054619789124, -0.2409885823726654, 0.1807170957326889, 0.6115837097167969, -0.0941145122051239, 0.0461755096912384, 0.43024155497550964, -0.3083013594150543, -0.7627171874046326, 0.5530532002449036, -0.6139274835586548, 0.23621803522109985, 0.2609193027019501, -0.2297067493200302, -0.0008069289615377784, 0.03912847861647606, 0.2540270984172821, -0.22306989133358002, 0.09312332421541214, 0.4739556908607483, -0.08705152571201324, -0.22567300498485565, 0.20006582140922546, 0.35307976603507996, 0.25948092341423035, 0.24211956560611725, 0.03130694478750229, -0.07853887230157852, 0.22602052986621857, -0.0704372301697731, 0.03416232764720917, -0.11776026338338852, -0.12753863632678986, 0.008889838121831417, 0.2639694809913635, -0.09329328685998917, -0.9264540672302246, -0.07197754085063934, -0.0367589071393013, 0.1022188737988472, 0.05176974833011627, 0.26203152537345886, -0.29992982745170593, -0.029021866619586945, 0.06497225165367126, -0.1291951984167099, -0.38625237345695496, 0.11690309643745422, 0.1185113862156868, 0.24272271990776062, 0.262472927570343, 0.16097083687782288, 0.11542830616235733, 0.17445558309555054, 0.3727520704269409, 0.2166178673505783, -0.2187117636203766, -0.110500767827034, 0.49913090467453003, 0.3866705596446991, -0.2009083479642868, 0.39531534910202026, -0.10414274781942368, -0.09404649585485458, -0.047233790159225464, -0.051134318113327026, 0.11930598318576813, 0.2957714796066284, -1.8688998073995356e-32, 0.3090101480484009, -0.035207293927669525, 0.10228459537029266, 0.15523241460323334, -0.3516155779361725, -0.24186694622039795, 0.2307966947555542, 0.6261171102523804, -0.12173392623662949, -0.1387108564376831, 0.08314633369445801, 0.5745512843132019, 0.1447436362504959, -0.3595413863658905, 0.4875447750091553, 0.033801719546318054, 0.057360660284757614, -0.25822412967681885, -0.20570367574691772, -0.32071560621261597, -0.442992240190506, -0.21580374240875244, 0.11751093715429306, -0.6702626943588257, -0.05911588296294212, 0.3055853545665741, -0.15811802446842194, -0.30923235416412354, -0.13824807107448578, -0.05023003742098808, 0.29466667771339417, 0.425378680229187, -0.07163284718990326, -0.17130911350250244, -0.09625395387411118, -0.18766318261623383, -0.2324817031621933, -0.05824776366353035, -0.3960610330104828, -0.05342433229088783, 0.08436707407236099, -0.1407494992017746, 0.5394018292427063, 0.0641387552022934, 0.16491274535655975, 0.050541918724775314, -0.15092507004737854, -0.16993428766727448, 0.11204676330089569, -0.05948324874043465, 0.17554451525211334, -0.2078125923871994, 0.04399089887738228, -0.15503466129302979, -0.20975297689437866, 0.20523013174533844, 0.5345446467399597, -0.372091680765152, 0.019904766231775284, -0.3152618706226349, 0.21370187401771545, -0.24445338547229767, -0.33944669365882874, 0.07489829510450363, 0.23821720480918884, 0.3586384654045105, -0.20256896317005157, -0.6122732758522034, 0.0716523602604866, 0.12169631570577621, -0.1138983890414238, -0.41037431359291077, -0.3793832063674927, -0.7090708017349243, 0.3202780783176422, 0.30810871720314026, -0.3246656656265259, -0.18448273837566376, 0.07211830466985703, 0.18330994248390198, -0.11752022802829742, -0.02875061333179474, 0.09281741082668304, -0.1586296111345291, 0.48297765851020813, -0.2621440887451172, -0.5812124013900757, 0.012395024299621582, 0.3410981297492981, 0.2559070587158203, -0.3251325786113739, -0.1265810877084732, -0.17997556924819946, 0.291291743516922, 0.7655881643295288, -1.3263699323710912e-32, 0.3705669939517975, 0.5070847272872925, 0.32374173402786255, 0.14061620831489563, -0.08490251004695892, 0.21699590981006622, -0.37692853808403015, 0.0038316561840474606, 0.18328511714935303, -0.033599819988012314, -0.4912641644477844, 0.16607971489429474, -0.24941565096378326, 0.4770824611186981, 0.04767335578799248, 0.37697210907936096, -0.5275960564613342, -0.3584613502025604, 0.052503351122140884, -0.2820015251636505, -0.7550234794616699, -0.04661082103848457, -0.21238116919994354, 0.36332249641418457, -0.41226187348365784, 0.30054864287376404, 0.02949555218219757, 0.290967732667923, -0.2242175042629242, 0.24296118319034576, -0.31037408113479614, -0.04020346701145172, -0.414406955242157, 0.17550675570964813, 0.0375775583088398, -0.0506928525865078, -0.23199187219142914, -0.35974735021591187, 0.1285807341337204, -0.23521524667739868, 0.5053567290306091, 0.11361119151115417, 0.27079156041145325, 0.07341847568750381, 0.25952664017677307, 0.057734210044145584, 0.3319664001464844, -0.01702756993472576, -0.02033366821706295, 0.43429383635520935, 0.061540763825178146, -0.07503935694694519, -0.5447854995727539, 0.3400037884712219, -0.43724706768989563, -0.20325671136379242, 0.418414443731308, -0.29303649067878723, 0.17178867757320404, 0.33645692467689514, 0.11780257523059845, 0.0864848867058754, 0.274946391582489, -0.007941422052681446]} 

ID: 3e1b444f-dbb0-4108-8c6e-eb2d6a7ceff5
Data: {
  "question": "It's the only living mammal in the order Proboseidea",
  "answer": "Elephant",
  "category": "ANIMALS"
}
Vector: {'default': [-0.22616049647331238, 0.17255128920078278, 0.07446679472923279, 0.024557063356041908, -0.1512775719165802, 0.175467848777771, -0.25066906213760376, -0.24152062833309174, -0.1525416076183319, 0.8464787602424622, 0.43047282099723816, -0.6525083184242249, -0.5413838624954224, 0.32440993189811707, -0.030541177839040756, 0.10262623429298401, 0.06005352362990379, -0.28439265489578247, 0.016964886337518692, 0.21273967623710632, -0.34655141830444336, 0.06466635316610336, -0.4484662413597107, -0.03925430774688721, -0.6978104710578918, 0.08350042998790741, -0.2890861928462982, -0.1247151717543602, -0.061069782823324203, -0.24763883650302887, -0.19699755311012268, -0.19395941495895386, 0.46032023429870605, 0.038393326103687286, -0.16674330830574036, -0.12732316553592682, -0.3827587366104126, -0.18735209107398987, 0.43800413608551025, 0.37947335839271545, 0.019338974729180336, 0.24982118606567383, -0.12262075394392014, -0.11478576064109802, -0.15824195742607117, 0.05440869182348251, 0.017683761194348335, 0.08883138746023178, -0.11767271906137466, -0.1465136706829071, 0.053397662937641144, -0.23732969164848328, -0.5960467457771301, 0.441634863615036, 0.1605074554681778, -0.329567015171051, -0.13652324676513672, 0.08647491782903671, 0.05262874811887741, -0.20710627734661102, 0.23931437730789185, 0.10869700461626053, 0.27622899413108826, 0.1643301248550415, -0.1481131613254547, 0.384000688791275, -0.09768355637788773, -0.29286253452301025, -0.2731155753135681, -0.27819323539733887, 0.15855033695697784, -0.3942725658416748, 0.025823723524808884, 0.024768363684415817, -0.15083660185337067, -0.07467453181743622, 0.07550052553415298, 0.04414019733667374, 0.013260445557534695, -0.19093088805675507, -0.3804345726966858, 0.0018254263559356332, -0.37509840726852417, 0.10029066354036331, 0.45176297426223755, -0.029504576697945595, 0.09965664148330688, -0.01741829141974449, -0.24442152678966522, -0.21815446019172668, 0.28686413168907166, 0.03801579773426056, 0.5383105278015137, -0.10920611023902893, -0.36916738748550415, -0.03100363351404667, -0.20374895632266998, 0.20253399014472961, -0.38362765312194824, -0.09245271980762482, -0.1150699332356453, -0.17778804898262024, 0.17363834381103516, 0.2028254121541977, -0.25378820300102234, -0.20289504528045654, -0.12568709254264832, 0.006944088730961084, 0.04449862986803055, 0.5454248785972595, -0.1124020516872406, -0.2298271358013153, 0.01563533954322338, 0.4765559732913971, 0.20358459651470184, -0.009745212271809578, -0.4267416000366211, -0.39617103338241577, 0.551562488079071, -0.4686659872531891, 0.2931423783302307, -0.2228897213935852, 0.47102487087249756, 0.010363908484578133, 0.32408443093299866, 0.12447920441627502, 0.22387413680553436, 1.3522366973158792e-30, 0.2156345695257187, -0.5528889298439026, 0.48289281129837036, -0.33531564474105835, 0.18961940705776215, 0.5200182199478149, -0.4461224377155304, 0.16865582764148712, 0.3624618947505951, -0.24893948435783386, -0.4249023199081421, -0.2949383556842804, 0.12244077771902084, 0.19554908573627472, -0.09530752897262573, 0.2682255804538727, -0.16898129880428314, 0.11389622092247009, 0.032004062086343765, 0.3711495101451874, -0.08651112765073776, 0.44220170378685, -0.04281306639313698, -0.4406067430973053, 0.1420910656452179, 0.253574013710022, -0.4665279984474182, -0.7377195954322815, -0.06090027466416359, 0.21470914781093597, 0.05222802609205246, 0.04373861849308014, -0.49780362844467163, 0.26966461539268494, -0.64342200756073, -0.3213569223880768, 0.020702578127384186, -0.1415048986673355, -0.19957385957241058, -0.1659100204706192, 0.26698869466781616, 0.08556236326694489, 0.1599758416414261, -0.13193705677986145, 0.21856369078159332, 0.1557849645614624, 0.24160680174827576, 0.24258363246917725, 0.323564350605011, -0.2801304757595062, -0.07425244897603989, 0.1218477115035057, 0.02875000238418579, -0.028328141197562218, 0.004532466176897287, 0.19739475846290588, -0.01007041521370411, 0.2816867232322693, -0.07477579265832901, -0.01176031306385994, 0.4399755001068115, 0.47106698155403137, 0.4985271692276001, 0.048616260290145874, 0.28106382489204407, -0.25930532813072205, -0.7697181701660156, 0.06360957771539688, 0.5979403257369995, -0.3830806612968445, 0.002482868265360594, -0.13819308578968048, 0.10331298410892487, -0.44997015595436096, 0.511317789554596, -0.14334586262702942, 0.3870539367198944, 0.18494780361652374, -0.4338734447956085, -0.421676903963089, -0.1673639565706253, 0.132266566157341, 0.06871116906404495, 0.13204386830329895, -0.011978770606219769, 0.49009668827056885, 0.1648285984992981, 0.2215014398097992, 0.09986961632966995, -0.02807408571243286, 0.41492602229118347, -0.20850788056850433, -0.34992295503616333, -0.09114693105220795, 0.17307822406291962, -1.7678707699237633e-32, -0.2574945390224457, -0.2373684197664261, 0.17501893639564514, -0.2470918595790863, 0.24496932327747345, -0.33670008182525635, -0.06682757288217545, 0.3748694062232971, -0.03876921907067299, -0.1849801391363144, 0.20149721205234528, -0.06665577739477158, 0.30535221099853516, -0.16028574109077454, 0.5436878800392151, 0.2843659520149231, -0.14792612195014954, -0.14765629172325134, 0.17140114307403564, -0.42330288887023926, 0.0636817067861557, -0.02337447740137577, 0.11565830558538437, -0.036692045629024506, -0.02073330618441105, 0.018503621220588684, -0.05773076415061951, 0.4331018328666687, 0.2541361153125763, -0.3114405870437622, 0.40438762307167053, 0.4535669684410095, -0.2185506522655487, -0.1951635181903839, -0.4908159375190735, -0.40976738929748535, -0.5071092844009399, 0.1492079198360443, 0.0795821100473404, 0.04898233711719513, 0.24153582751750946, 0.27358296513557434, -0.45845749974250793, 0.02737211063504219, 0.5054060816764832, -0.23771576583385468, 0.004760855808854103, 0.050168950110673904, -0.011908258311450481, 0.2663745880126953, -0.11681999266147614, -0.08819931000471115, 0.03849499672651291, -0.5919158458709717, 0.19198735058307648, 0.3744652569293976, -0.06688918173313141, -0.08295394480228424, 0.1309565305709839, -0.021334944292902946, 0.25988173484802246, 0.19464829564094543, 0.05214082449674606, 0.11498435586690903, -0.07628052681684494, 0.20749616622924805, -0.02611483633518219, 0.7170276641845703, 0.2325013279914856, -0.11207910627126694, 0.20010194182395935, 0.11966904997825623, -0.5759344696998596, -0.4856182336807251, 0.3127107322216034, 0.5606446266174316, -0.12247616797685623, -0.14866477251052856, 0.4102834165096283, -0.44498252868652344, -0.7993278503417969, -0.11581257730722427, 0.15071676671504974, -0.08826494216918945, 0.09758799523115158, -0.39726412296295166, -0.06944077461957932, -0.20946763455867767, 0.28263360261917114, 0.3109687268733978, -0.10180649161338806, -0.02801048755645752, 0.20712058246135712, 0.0688941478729248, 0.37266331911087036, -1.7499590278163148e-32, 0.5371081233024597, 0.25157007575035095, 0.43418774008750916, 0.2753012180328369, 0.18174146115779877, -0.35794585943222046, 0.17461687326431274, -0.007030753884464502, -0.007501634769141674, 0.11434591561555862, 0.014076238498091698, -0.048177026212215424, 0.2129158228635788, 0.7188690900802612, 0.16103480756282806, 0.028168894350528717, -0.23483212292194366, -0.6658362746238708, -0.19520841538906097, -0.23225489258766174, -0.4167413115501404, -0.31853240728378296, -0.13481684029102325, -0.1459033340215683, -0.09565810859203339, -0.07833251357078552, 0.3396557867527008, -0.4236724376678467, 0.20464865863323212, 0.4748855233192444, -0.5811280608177185, 0.08428741991519928, -0.12143193930387497, -0.2686466574668884, 0.26562976837158203, 0.2436939924955368, -0.027247145771980286, -0.26779675483703613, -0.23676468431949615, -0.5054488182067871, 0.44075462222099304, -0.11053577810525894, 0.1951267123222351, 0.1357799619436264, 0.4287467300891876, -0.18657542765140533, 0.2065320461988449, -0.3218112885951996, 0.05165109038352966, -0.34773942828178406, -0.20673812925815582, 0.19246651232242584, -0.08326742798089981, -0.2609612047672272, -0.3184228539466858, -0.04861773923039436, -0.041826147586107254, 0.14864900708198547, 0.23142974078655243, -0.051865775138139725, 0.30101194977760315, -0.13410604000091553, 0.4391515851020813, 0.41133227944374084]} 

ID: aac57491-eced-4033-866c-a0ca20f20a35
Data: {
  "question": "Heaviest of all poisonous snakes is this North American rattlesnake",
  "answer": "the diamondback rattler",
  "category": "ANIMALS"
}
Vector: {'default': [0.09574556350708008, -0.13571687042713165, -0.2824910283088684, -0.04742668569087982, 0.03194054961204529, -0.35583600401878357, 0.20167429745197296, 0.2698567509651184, -0.5160923600196838, -0.06658799201250076, -0.5676759481430054, -0.1835748851299286, 0.15648864209651947, 0.07276665419340134, -0.2664348781108856, 0.14514502882957458, 0.27336183190345764, 0.0381632000207901, 0.10384909808635712, 0.16901232302188873, -0.6278858780860901, 0.4020540714263916, -0.08861060440540314, 0.3858792185783386, -0.5853688716888428, -0.07657556980848312, -0.27941808104515076, 0.07988140732049942, 0.05653269961476326, -0.6379948258399963, 0.07313906401395798, -0.24939021468162537, -0.3860076069831848, -0.2719229757785797, -0.0856979489326477, -0.5407840609550476, -0.24149729311466217, -0.12566210329532623, 0.14509853720664978, 0.30097541213035583, 0.21124298870563507, 0.8758403062820435, -0.30474746227264404, 0.04886314272880554, -0.4886661469936371, 0.11148186028003693, -0.46883952617645264, 0.17799341678619385, 0.02853912115097046, -0.41421833634376526, 0.3787623643875122, -0.07296174764633179, -0.4281393885612488, -0.07711363583803177, 0.30286794900894165, -0.36133110523223877, 0.3784032166004181, -0.19293387234210968, 0.10189706087112427, 0.16846886277198792, 0.2465251386165619, 0.255827397108078, 0.5835920572280884, -0.06585891544818878, 0.3105478584766388, 0.20992815494537354, -0.027143161743879318, -0.40962347388267517, 0.05031844973564148, -0.15248923003673553, 0.0839022770524025, -0.38497790694236755, -0.3654254376888275, 0.16097094118595123, 0.1416759192943573, -0.25791987776756287, 0.21000754833221436, 0.3002563416957855, -0.6664038300514221, 0.3614175319671631, -0.8282651305198669, -0.015592699870467186, 0.2840270698070526, -0.6526656150817871, 0.5429216623306274, -0.011158650740981102, -0.13043321669101715, 0.3312198519706726, -0.23828187584877014, 0.7615121006965637, 0.7232332825660706, -0.012677804566919804, 0.46075621247291565, 0.33399245142936707, -0.391798198223114, -0.1335592120885849, 0.24089489877223969, -0.12614265084266663, -0.522148072719574, -0.07581138610839844, 0.0028013885021209717, -0.5909090638160706, 0.10362916439771652, 0.3854709565639496, -0.12592220306396484, -0.03353450447320938, -0.010177591815590858, -0.41309961676597595, -0.15696685016155243, 0.1989845335483551, -0.03558824211359024, 0.10546398162841797, -0.23856689035892487, 0.3103558123111725, -0.24963237345218658, -0.5310165286064148, -0.19332939386367798, -0.07220106571912766, 0.2191188484430313, -0.0940144807100296, 0.10517984628677368, -0.05830570310354233, 0.011011571623384953, -0.02150123007595539, 0.012724588625133038, -0.02984515018761158, -0.39517009258270264, 1.3097354295280005e-30, -0.26670390367507935, 0.021057218313217163, 0.5818017721176147, -0.3195914924144745, 0.08060798794031143, -0.2511807084083557, -0.32895371317863464, -0.031012576073408127, 0.21882696449756622, -0.16700083017349243, -0.17848268151283264, -0.2084871232509613, -0.25663575530052185, 0.10783953964710236, -0.08018357306718826, 0.09405237436294556, -0.16738072037696838, -0.35844942927360535, -0.36879557371139526, -0.30161023139953613, 0.00484237726777792, -0.37134742736816406, 0.06723523885011673, -0.11744167655706406, 0.06162440404295921, 0.08078479766845703, -0.6432496905326843, -0.09179536253213882, -0.15608029067516327, -0.11994807422161102, 0.4021356701850891, -0.025233667343854904, 0.3628423810005188, 0.24576112627983093, -0.007188245188444853, -0.04628210887312889, 0.05489762872457504, 0.0036906003952026367, -0.0017471339087933302, -0.23364681005477905, 0.35823899507522583, 0.026044238358736038, -0.09542492032051086, 0.7732062935829163, 0.5435343980789185, -0.11974125355482101, 0.16997145116329193, 0.2787307798862457, -0.5020351409912109, -0.257412314414978, -0.059692952781915665, -0.34801143407821655, 0.006648315116763115, 0.36154428124427795, -0.26417306065559387, 0.4498099982738495, -0.09607680886983871, -0.2973794639110565, -0.08108572661876678, 0.17561674118041992, 0.25903359055519104, 0.2208804041147232, 0.8380151987075806, -0.34670236706733704, 0.19347353279590607, -0.12809190154075623, -0.07235364615917206, -0.2753332853317261, 0.20794406533241272, -0.41377589106559753, 0.4528529942035675, 0.27466773986816406, 0.5825821161270142, -0.14116834104061127, 0.06775034219026566, 0.006010749842971563, 0.007872678339481354, 0.007284864317625761, -0.04167510196566582, 0.09996099770069122, 0.013607836328446865, 0.1661258041858673, 0.3258763551712036, -0.3639799952507019, 0.11051943898200989, -0.0412304624915123, 0.06098674237728119, -0.6683269739151001, 0.1888756901025772, 0.8085131645202637, 0.16612815856933594, -0.1836892068386078, -0.16344651579856873, -0.19314628839492798, -0.18461941182613373, -1.6396682703504137e-32, -0.17399561405181885, 0.25118809938430786, 0.655360996723175, 0.36905890703201294, 0.0011316732270643115, -0.49062156677246094, -0.2221790999174118, 0.13405795395374298, -0.18906089663505554, -0.44305819272994995, 0.006187643855810165, 0.07618935406208038, 0.3011022210121155, 0.29584065079689026, 0.7789912223815918, -0.10605626553297043, 0.25671058893203735, 0.056004274636507034, -0.155104860663414, -0.5407944321632385, -0.06132778897881508, -0.688025951385498, -0.42089200019836426, -0.39969146251678467, -0.2880547046661377, -0.2891966700553894, -0.31379935145378113, -0.12641523778438568, 0.3166455924510956, -0.33021989464759827, 0.14840447902679443, 0.5445775389671326, 0.28946205973625183, 0.19029533863067627, -0.4328227639198303, -0.42244115471839905, 0.18473577499389648, 0.036570917814970016, 0.23122501373291016, 0.20221303403377533, -0.022954870015382767, 0.35353904962539673, -0.37162694334983826, -0.12276758253574371, -0.17952336370944977, 0.09666162729263306, 0.5055904984474182, 0.05888091400265694, -0.010810167528688908, 0.017269697040319443, 0.4920575022697449, -0.03070126846432686, 0.1542937308549881, 0.4264257252216339, 0.33509284257888794, 0.17522817850112915, 0.70722496509552, 0.1511019766330719, 0.06937625259160995, -0.16515733301639557, 0.24118442833423615, 0.3143250048160553, -0.5597126483917236, 0.04831366986036301, 0.1189534068107605, 0.07410799711942673, -0.02626635506749153, -0.05771331116557121, -0.11533956974744797, -0.02920243702828884, -0.02076057158410549, 0.326964795589447, 0.22407175600528717, -0.5301578640937805, 0.04281938076019287, 0.08463509380817413, -0.1190761923789978, -0.10081128776073456, 0.0961524099111557, -0.3086785674095154, -0.3937426507472992, 0.22431129217147827, -0.17854014039039612, -0.19894175231456757, -0.18926674127578735, 0.31993210315704346, -0.0683293268084526, 0.0935429260134697, 0.036456357687711716, 0.2919318974018097, -0.15002739429473877, -0.34658530354499817, 0.0914376825094223, 0.2733631730079651, 0.4848597049713135, -1.2102693675446479e-32, 0.3309108018875122, 0.17961415648460388, -0.046828120946884155, -0.1217656210064888, 0.033547453582286835, 0.7026333212852478, 0.5723090171813965, 0.17668046057224274, -0.4470710754394531, -0.11509434878826141, 0.24266023933887482, -0.2063336819410324, 0.05687239393591881, -0.09728135913610458, -0.030990973114967346, -0.038012515753507614, -0.08368046581745148, -0.07279429584741592, 0.0006799775874242187, -0.04014608636498451, -0.3355877697467804, 0.7041743993759155, 0.005834309849888086, 0.08151431381702423, -0.17458276450634003, 0.021725572645664215, 0.017652515321969986, 0.0904383584856987, 0.14237186312675476, 0.4733847677707672, 0.14242327213287354, -0.3788415193557739, 0.03570884093642235, -0.36537158489227295, 0.021344780921936035, -0.02736850082874298, -0.5471708178520203, -0.06486155837774277, 0.10504751652479172, 0.16887982189655304, 0.4125846326351166, 0.091273233294487, 0.48386722803115845, 0.06190041825175285, 0.0420527458190918, 0.02877959981560707, -0.5449330806732178, -0.1857319474220276, 0.19494450092315674, -0.1865631639957428, 0.4759792983531952, -0.26015618443489075, -0.006098455749452114, -0.23495341837406158, 0.2042696177959442, 0.18668508529663086, 0.05043260008096695, 0.25614237785339355, -0.42004212737083435, 0.07440350204706192, 0.3487650454044342, -0.6086697578430176, 0.27968502044677734, 0.40973472595214844]} 

[9]

Now, also request the distance for each returned item.

[10]
ID: 8a00fbd2-45fa-48f2-8854-0ed373f03613
Distance: 0.46423041820526123
Data: {'question': 'Weighing around a ton, the eland is the largest species of this animal in Africa', 'answer': 'Antelope', 'category': 'ANIMALS'} 

ID: 7727cb1f-a08d-40b0-9da6-e4746f3337fa
Distance: 0.5695910453796387
Data: {'question': 'The gavial looks very much like a crocodile except for this bodily feature', 'answer': 'the nose or snout', 'category': 'ANIMALS'} 

ID: 3e1b444f-dbb0-4108-8c6e-eb2d6a7ceff5
Distance: 0.5756919980049133
Data: {'question': "It's the only living mammal in the order Proboseidea", 'answer': 'Elephant', 'category': 'ANIMALS'} 

ID: aac57491-eced-4033-866c-a0ca20f20a35
Distance: 0.7628661394119263
Data: {'question': 'Heaviest of all poisonous snakes is this North American rattlesnake', 'answer': 'the diamondback rattler', 'category': 'ANIMALS'} 

nearObject Example

Search through the JeopardyQuestion class to find the top 4 objects closest to UUID, we saved earlier.

[14]
Retrieve objects closest to item with UUID: aac57491-eced-4033-866c-a0ca20f20a35

ID: aac57491-eced-4033-866c-a0ca20f20a35
Data: {'question': 'Heaviest of all poisonous snakes is this North American rattlesnake', 'answer': 'the diamondback rattler', 'category': 'ANIMALS'} 

ID: 8a00fbd2-45fa-48f2-8854-0ed373f03613
Data: {'question': 'Weighing around a ton, the eland is the largest species of this animal in Africa', 'answer': 'Antelope', 'category': 'ANIMALS'} 

ID: 3e1b444f-dbb0-4108-8c6e-eb2d6a7ceff5
Data: {'question': "It's the only living mammal in the order Proboseidea", 'answer': 'Elephant', 'category': 'ANIMALS'} 

ID: 7727cb1f-a08d-40b0-9da6-e4746f3337fa
Data: {'question': 'The gavial looks very much like a crocodile except for this bodily feature', 'answer': 'the nose or snout', 'category': 'ANIMALS'} 

nearVector Example

Search through the JeopardyQuestion class to find the top 2 objects closest to the query vector, we saved earlier.

[17]
Retrieve objects closest to item with vector: [0.09574556350708008, -0.13571687042713165, -0.2824910283088684, -0.04742668569087982, 0.03194054961204529]...

ID: aac57491-eced-4033-866c-a0ca20f20a35
Data: {'question': 'Heaviest of all poisonous snakes is this North American rattlesnake', 'answer': 'the diamondback rattler', 'category': 'ANIMALS'} 

ID: 8a00fbd2-45fa-48f2-8854-0ed373f03613
Data: {'question': 'Weighing around a ton, the eland is the largest species of this animal in Africa', 'answer': 'Antelope', 'category': 'ANIMALS'} 

ID: 3e1b444f-dbb0-4108-8c6e-eb2d6a7ceff5
Data: {'question': "It's the only living mammal in the order Proboseidea", 'answer': 'Elephant', 'category': 'ANIMALS'} 

ID: 7727cb1f-a08d-40b0-9da6-e4746f3337fa
Data: {'question': 'The gavial looks very much like a crocodile except for this bodily feature', 'answer': 'the nose or snout', 'category': 'ANIMALS'}