Notebooks
N
Nebius
1 Process Pdfs

1 Process Pdfs

rag-milvus-1nebius-token-factory-cookbookrag

Step-1: Configuration

[1]
✅ Found NEBIUS_API_KEY in environment, using it

Step-2: Read documents

[2]
Loaded 545 chunks
CPU times: user 12.2 s, sys: 158 ms, total: 12.4 s
Wall time: 11.5 s

Step-3: Setup Embedding Model

We have a choice of local embedding model (fast) or running it on the cloud

If running locally:

  • choose smaller models
  • less accuracy but faster

If running on the cloud

  • We can run large models (billions of params)
[ ]

Step-4: Connect to Milvus

[4]
/home/sujee/my-stuff/projects/nebius/token-factory-cookbook-1/rag/rag-milvus-1/.venv/lib/python3.13/site-packages/google/protobuf/runtime_version.py:98: UserWarning: Protobuf gencode version 5.27.2 is exactly one major version older than the runtime version 6.31.1 at schema.proto. Please update the gencode to avoid compatibility violations in the next runtime release.
  warnings.warn(
/home/sujee/my-stuff/projects/nebius/token-factory-cookbook-1/rag/rag-milvus-1/.venv/lib/python3.13/site-packages/google/protobuf/runtime_version.py:98: UserWarning: Protobuf gencode version 5.27.2 is exactly one major version older than the runtime version 6.31.1 at common.proto. Please update the gencode to avoid compatibility violations in the next runtime release.
  warnings.warn(
/home/sujee/my-stuff/projects/nebius/token-factory-cookbook-1/rag/rag-milvus-1/.venv/lib/python3.13/site-packages/google/protobuf/runtime_version.py:98: UserWarning: Protobuf gencode version 5.27.2 is exactly one major version older than the runtime version 6.31.1 at milvus.proto. Please update the gencode to avoid compatibility violations in the next runtime release.
  warnings.warn(
/home/sujee/my-stuff/projects/nebius/token-factory-cookbook-1/rag/rag-milvus-1/.venv/lib/python3.13/site-packages/google/protobuf/runtime_version.py:98: UserWarning: Protobuf gencode version 5.27.2 is exactly one major version older than the runtime version 6.31.1 at rg.proto. Please update the gencode to avoid compatibility violations in the next runtime release.
  warnings.warn(
/home/sujee/my-stuff/projects/nebius/token-factory-cookbook-1/rag/rag-milvus-1/.venv/lib/python3.13/site-packages/google/protobuf/runtime_version.py:98: UserWarning: Protobuf gencode version 5.27.2 is exactly one major version older than the runtime version 6.31.1 at feder.proto. Please update the gencode to avoid compatibility violations in the next runtime release.
  warnings.warn(
/home/sujee/my-stuff/projects/nebius/token-factory-cookbook-1/rag/rag-milvus-1/.venv/lib/python3.13/site-packages/google/protobuf/runtime_version.py:98: UserWarning: Protobuf gencode version 5.27.2 is exactly one major version older than the runtime version 6.31.1 at msg.proto. Please update the gencode to avoid compatibility violations in the next runtime release.
  warnings.warn(
/home/sujee/my-stuff/projects/nebius/token-factory-cookbook-1/rag/rag-milvus-1/.venv/lib/python3.13/site-packages/milvus_lite/__init__.py:15: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  from pkg_resources import DistributionNotFound, get_distribution
✅ Connected to Milvus instance:  ./rag.db
✅ Cleared collection : rag
[5]
✅ Connected Llama-index to Milvus instance:  ./rag.db
CPU times: user 17.3 ms, sys: 5.96 ms, total: 23.2 ms
Wall time: 554 ms

Step-5: Create Index and Save to DB

[6]
2025-08-13 23:20:37,445 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:20:44,626 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:20:51,232 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:20:57,390 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:02,770 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:08,161 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:12,936 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:18,637 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:25,015 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:30,860 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:36,920 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:42,771 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:48,807 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:21:55,170 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:22:01,386 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
2025-08-13 23:22:03,877 - INFO - HTTP Request: POST https://api.tokenfactory.nebius.com/v1/embeddings "HTTP/1.1 200 OK"
✅ Created index: <llama_index.core.indices.vector_store.base.VectorStoreIndex object at 0x705a2b6c4050>
✅ Saved index to db  ./rag.db
CPU times: user 3.72 s, sys: 460 ms, total: 4.18 s
Wall time: 1min 33s