Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update simple OSS RAG demo #1189

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions notebooks/llms/langchain/readthedocs_rag_milvus_client.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -740,28 +740,15 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0th query result\n",
"id: 445782430324621984, distance: 0.7082178592681885, entity: {'chunk': \"index_file_size (int) – Segment size. See Storage Concepts. metric_type (MetricType) – Distance Metrics type. Valued form MetricType. See Distance Metrics. A demo is as follow: param={'collection_name': 'name', 'dimension': 16, 'index_file_size': 1024 # Optional, default 1024, 'metric_type': MetricType.L2 # Optional, default MetricType.L2 } timeout (float) – An optional duration of time in seconds to allow for the RPC. When timeout is set to None, client waits until server responses or error occurs.\", 'source': 'https://pymilvus.readthedocs.io/en/latest/api.html', 'h1': 'API reference', 'h2': 'Client'}\n",
"id: 445782430324622095, distance: 0.690363883972168, entity: {'chunk': 'A metric for binary vectors, only support :attr:`~milvus.IndexType.FLAT` index. #: See `Substructure `_. SUPERSTRUCTURE = 7 def __repr__(self): return \"\".format(self.__class__.__name__, self._name_) def __str__(self): return self._name_', 'source': 'https://pymilvus.readthedocs.io/en/latest/_modules/milvus/client/types.html', 'h1': 'Source code for milvus.client.types from enum import IntEnum class Status: \"\"\" :attribute code: int (optional) default as ok :attribute message: str (optional) current status message \"\"\" SUCCESS = 0 U', 'h2': ''}\n",
"id: 445782430324621945, distance: 0.6885938048362732, entity: {'chunk': 'you can refer to Storage Concepts for more information about segments and index_file_size. metric_type:Milvus compute distance between two vectors, you can refer to Distance Metrics for more information. Now we can create a collection: >>> collection_name = \\'demo_film_tutorial\\' >>> collection_param = { ... \"collection_name\": collection_name, ... \"dimension\": 8, ... \"index_file_size\": 2048, ... \"metric_type\": MetricType.L2 ... } >>> client.create_collection(collection_param) Status(code=0, message=\\'Create', 'source': 'https://pymilvus.readthedocs.io/en/latest/tutorial.html', 'h1': 'Tutorial', 'h2': 'This is a basic introduction to Milvus by PyMilvus. For a runnable python script, checkout example.py on PyMilvus Github, or hello milvus on Milvus official website. It’s a good recommended start to g'}\n",
"id: 445782430324621947, distance: 0.6716917157173157, entity: {'chunk': \"metric_type=) The attributes of collection can be extracted from info. >>> info.collection_name 'demo_film_tutorial' >>> info.dimension 8 >>> info.index_file_size 2048 >>> info.metric_type This tutorial is a basic intro tutorial, building index won’t be covered by this tutorial. If you want to go further into Milvus with indexes, it’s recommended to check our index examples. If you’re already known about indexes from index examples, and you want a full lists of params supported by PyMilvus, you check out\", 'source': 'https://pymilvus.readthedocs.io/en/latest/tutorial.html', 'h1': 'Tutorial', 'h2': 'This is a basic introduction to Milvus by PyMilvus. For a runnable python script, checkout example.py on PyMilvus Github, or hello milvus on Milvus official website. It’s a good recommended start to g'}\n",
"id: 445782430324622037, distance: 0.6690606474876404, entity: {'chunk': \"-- Segment size. See `Storage Concepts `_. * *metric_type* (``MetricType``) -- Distance Metrics type. Valued form :class:`~milvus.MetricType`. See `Distance Metrics `_. A demo is as follow: .. code-block:: python param={'collection_name': 'name', 'dimension': 16, 'index_file_size': 1024 # Optional, default 1024, 'metric_type': MetricType.L2 # Optional, default MetricType.L2 } :param timeout: An optional duration of time in seconds to allow for the RPC. When timeout is set to None, client waits until\", 'source': 'https://pymilvus.readthedocs.io/en/latest/_modules/milvus/client/stub.html', 'h1': 'Source code for milvus.client.stub # -*- coding: UTF-8 -*- import collections import copy import functools import logging from urllib.parse import urlparse from . import __version__ from .types import', 'h2': ''}\n",
"2267\n"
]
}
],
"outputs": [],
"source": [
"for n, hits in enumerate(results):\n",
" print(f\"{n}th query result\")\n",
" for hit in hits:\n",
" print(hit)\n",
"# # TODO - remove this before saving in github.\n",
"# for n, hits in enumerate(results):\n",
"# print(f\"{n}th query result\")\n",
"# for hit in hits:\n",
"# print(hit)\n",
"\n",
"# Assemble the context as a stuffed string.\n",
"context = \"\"\n",
Expand Down