from llama_index import Document, ServiceContext, VectorStoreIndex, Document, load_index_from_storage, StorageContext
# define your service context
service_context = ServiceContext.from_defaults(
llm=llm,embed_model="local:BAAI/bge-small-en-v1.5"
)
# load data
pg_essay = [Document(text="this is first data")]
# build index and query engine
vector_index = VectorStoreIndex.from_documents(
pg_essay, use_async=True, service_context=service_context
)
print(vector_index.service_context.embed_model)
vector_index.storage_context.persist()
storage_context = StorageContext.from_defaults()
# load a single index
# need to specify index_id if multiple indexes are persisted to the same directory
index = load_index_from_storage(storage_context, service_context=service_context)
print(index.service_context.embed_model)
replace the llm with your llm and check once running in a fresh colab session
also do this at the top
!pip install llama_index==0.9.7
!pip install transformers