You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/docs/docs/integrations/text_embedding/anyscale.ipynb

123 lines
46 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "42f76e43",
"metadata": {},
"source": [
"# Anyscale\n",
"\n",
"Let's load the Anyscale Embedding class."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "6b82f59f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from langchain_community.embeddings import AnyscaleEmbeddings"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "26895c60",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"embeddings = AnyscaleEmbeddings(\n",
" anyscale_api_key=\"ANYSCALE_API_KEY\", model=\"thenlper/gte-large\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "eea52814",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"text = \"This is a test document.\""
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "fbe167bf",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[-0.0011281073475422098, -0.013280618454218683, 0.02164546846135075, 0.025931981339009518, -0.02797745821741894, -0.0024417192570683178, -0.011125238057702404, 0.015363551265202351, 0.02192303426295283, 0.05095556178384907, 0.024389593756572448, 0.019081919168881186, 0.013637039340883703, -0.0247996346109641, -0.02173890992107125, 0.012264976693272853, -0.026305749040536737, -0.013048393162374534, -0.021480663475611197, -0.023933815648992645, -0.032076296551421475, 0.01402027021141204, -0.06854003899926611, -0.024963651697778845, -0.016237648753819896, 0.045055692678519194, 0.012126587741934215, -0.009233428477985552, 0.056538434751077574, 0.044508443789853504, -0.015730223219793293, -0.023026992415317502, -0.0023273807807109637, -0.051875000713547156, -0.013952062006382637, -0.028486856292725373, 0.06940428402603317, -0.032273431470111004, -0.004280992462910799, -0.056008534539919295, 0.005817466146798797, -0.002677887535996265, 0.04502257484664441, -0.03952801733951214, -0.0560842361666378, -0.018278394513390066, -0.025467528892676006, -0.02268792020615989, -0.01901814592210228, -0.027318236411815525, 0.023777882442399305, 0.008590668730768492, 0.013483668202779889, -0.00568696223830515, 0.001981407936703065, -0.012875997897394839, 0.0050133505671140725, -0.024504720131854608, -0.04513612542407695, 0.05519791506881451, 0.03348463142057415, 0.0047798190953147945, 0.026994935219670505, -0.049372168067063106, 0.008109362139231437, 0.01112986486840977, -0.0010968614741057904, -0.009569938618653637, 0.014773623586787115, -0.03330642097724164, -0.003996821721385883, 0.01651324573943257, -0.012862691159998132, -0.028014519269208178, 0.010579469040657893, -0.011088472235179317, 0.009126975510134493, 0.004980971274065965, -0.02462536738754604, 0.004857170094368798, 0.013695785308234598, 0.03694948306630958, 0.012812224650615935, -0.004066718879961544, -0.05353566812961081, -0.0260747065284024, -0.0003661297502111736, 0.009114358882788942, 0.0405215783727887, 0.0027789686350550365, 0.005081756678197284, 0.05137506673856444, -0.012004116956579937, -0.0038727744396900403, 0.011447850071118874, 0.0411303318063647, -0.030835132227427977, 0.02303027067089116, 0.016135927836130697, 0.010270755154493038, 0.049094604128106234, 0.0463473253745401, 0.007873834377425872, 0.05548494497074031, -0.053393730839142735, -0.0036492721482057682, 0.001354123162325162, -0.02372327527271015, -0.012537418357895883, -0.04214755215912796, 7.776991960378352e-05, -0.01903736655804806, -0.004505727127033662, 0.005716532662373101, -0.026562814568932187, 0.04493425566125774, -0.0010509966297205936, 0.04416148514086699, -0.030582799680516994, 0.0033304303615296553, 0.0239464332076608, 0.016964685746312918, 0.0023076672422758806, -0.029742213973236637, -0.017173648462100587, -0.029750098550420326, -0.021255139981240925, 0.041672849576191134, -0.017011209035780663, -0.01737866982061902, 0.029046720877414004, -0.03624452773280844, -0.0279238363870471, 0.05001877417664358, -0.0021706580453782574, 0.013980843600203177, 0.017699212435204618, 0.015974313561639825, 0.014851393681013887, -0.06198568106981729, 0.02009361864123517, 0.044281346360278834, 0.009866824707720354, 0.094114023653761, 0.018390367430327792, 0.03247214591194057, 0.0016862963664470462, -0.017471716399554513, -0.0394743955091403, 0.04718948687967007, -0.02795971465912652, -0.00392925380064821, 0.006897176849450984, 0.025026735765829197, -0.014751839951029206, -0.009028062530102843, -0.013324160580024134, -0.004594634908307413, 0.002389872527583803, 0.02091133665324406, -0.04512666318639845, 0.022915019498379777, -0.01987125046785454, 0.017672794538158492, -0.029502497122348596, 0.057062028045546984, -0.024816193526901495, -0.013688294680513313, -0.034900852729555724, -0.0509839484968846, 0.03281279391894779, -0.0011022333428980786, -0.02453862772529941, 0.018217677867404553, 0.020660185023397677, 0.03529512256693479, 0.049132453078820276, 0.013496284830125438, 0.03760239609257892, 0.03283487371529446, -0.017583689316492238, 0.0043452588450096615, 0.01377680851232466, 0.07458342119291368, 0.
]
}
],
"source": [
"query_result = embeddings.embed_query(text)\n",
"print(query_result)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "38ad3b20",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[-0.0011281073475422098, -0.013280618454218683, 0.02164546846135075, 0.025931981339009518, -0.02797745821741894, -0.0024417192570683178, -0.011125238057702404, 0.015363551265202351, 0.02192303426295283, 0.05095556178384907, 0.024389593756572448, 0.019081919168881186, 0.013637039340883703, -0.0247996346109641, -0.02173890992107125, 0.012264976693272853, -0.026305749040536737, -0.013048393162374534, -0.021480663475611197, -0.023933815648992645, -0.032076296551421475, 0.01402027021141204, -0.06854003899926611, -0.024963651697778845, -0.016237648753819896, 0.045055692678519194, 0.012126587741934215, -0.009233428477985552, 0.056538434751077574, 0.044508443789853504, -0.015730223219793293, -0.023026992415317502, -0.0023273807807109637, -0.051875000713547156, -0.013952062006382637, -0.028486856292725373, 0.06940428402603317, -0.032273431470111004, -0.004280992462910799, -0.056008534539919295, 0.005817466146798797, -0.002677887535996265, 0.04502257484664441, -0.03952801733951214, -0.0560842361666378, -0.018278394513390066, -0.025467528892676006, -0.02268792020615989, -0.01901814592210228, -0.027318236411815525, 0.023777882442399305, 0.008590668730768492, 0.013483668202779889, -0.00568696223830515, 0.001981407936703065, -0.012875997897394839, 0.0050133505671140725, -0.024504720131854608, -0.04513612542407695, 0.05519791506881451, 0.03348463142057415, 0.0047798190953147945, 0.026994935219670505, -0.049372168067063106, 0.008109362139231437, 0.01112986486840977, -0.0010968614741057904, -0.009569938618653637, 0.014773623586787115, -0.03330642097724164, -0.003996821721385883, 0.01651324573943257, -0.012862691159998132, -0.028014519269208178, 0.010579469040657893, -0.011088472235179317, 0.009126975510134493, 0.004980971274065965, -0.02462536738754604, 0.004857170094368798, 0.013695785308234598, 0.03694948306630958, 0.012812224650615935, -0.004066718879961544, -0.05353566812961081, -0.0260747065284024, -0.0003661297502111736, 0.009114358882788942, 0.0405215783727887, 0.0027789686350550365, 0.005081756678197284, 0.05137506673856444, -0.012004116956579937, -0.0038727744396900403, 0.011447850071118874, 0.0411303318063647, -0.030835132227427977, 0.02303027067089116, 0.016135927836130697, 0.010270755154493038, 0.049094604128106234, 0.0463473253745401, 0.007873834377425872, 0.05548494497074031, -0.053393730839142735, -0.0036492721482057682, 0.001354123162325162, -0.02372327527271015, -0.012537418357895883, -0.04214755215912796, 7.776991960378352e-05, -0.01903736655804806, -0.004505727127033662, 0.005716532662373101, -0.026562814568932187, 0.04493425566125774, -0.0010509966297205936, 0.04416148514086699, -0.030582799680516994, 0.0033304303615296553, 0.0239464332076608, 0.016964685746312918, 0.0023076672422758806, -0.029742213973236637, -0.017173648462100587, -0.029750098550420326, -0.021255139981240925, 0.041672849576191134, -0.017011209035780663, -0.01737866982061902, 0.029046720877414004, -0.03624452773280844, -0.0279238363870471, 0.05001877417664358, -0.0021706580453782574, 0.013980843600203177, 0.017699212435204618, 0.015974313561639825, 0.014851393681013887, -0.06198568106981729, 0.02009361864123517, 0.044281346360278834, 0.009866824707720354, 0.094114023653761, 0.018390367430327792, 0.03247214591194057, 0.0016862963664470462, -0.017471716399554513, -0.0394743955091403, 0.04718948687967007, -0.02795971465912652, -0.00392925380064821, 0.006897176849450984, 0.025026735765829197, -0.014751839951029206, -0.009028062530102843, -0.013324160580024134, -0.004594634908307413, 0.002389872527583803, 0.02091133665324406, -0.04512666318639845, 0.022915019498379777, -0.01987125046785454, 0.017672794538158492, -0.029502497122348596, 0.057062028045546984, -0.024816193526901495, -0.013688294680513313, -0.034900852729555724, -0.0509839484968846, 0.03281279391894779, -0.0011022333428980786, -0.02453862772529941, 0.018217677867404553, 0.020660185023397677, 0.03529512256693479, 0.049132453078820276, 0.013496284830125438, 0.03760239609257892, 0.03283487371529446, -0.017583689316492238, 0.0043452588450096615, 0.01377680851232466, 0.07458342119291368, 0
]
}
],
"source": [
"doc_result = embeddings.embed_documents([text])\n",
"print(doc_result)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
},
"vscode": {
"interpreter": {
"hash": "7377c2ccc78bc62c2683122d48c8cd1fb85a53850a1b1fc29736ed39852c9885"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}