8.2.8.1 Inferring Embeddings for a Model in Another Database
You can infer embeddings on a trained model and store in a different database other than the one used for login.
The following code shows how to infer embeddings and store in a different database:
Inferring Embeddings Using JShell
opg-jshell> var vertexVectors = model.inferEmbeddings(fullGraph, fullGraph.getVertices()).flattenAll()
opg-jshell> vertexVectors.write()
.db()
.username("user") // DB user to use for storing the model
.password("password") // password of the DB user
.jdbcUrl("jdbcUrl") // jdbc url to the DB
.name("vertex vectors")
.tablename("vertexVectors") // indicate the name of the table in which the data should be stored
.overwrite(true) // indicate that if there is a table with the same name, it will be overwritten (truncated)
.store()
Inferring Embeddings Using Java
PgxFrame vertexVectors = model.inferEmbeddings(fullGraph,fullGraph.getVertices()).flattenAll();
vertexVectors.write()
.db()
.username("user") // DB user to use for storing the model
.password("password") // password of the DB user
.jdbcUrl("jdbcUrl") // jdbc url to the DB
.name("vertex vectors")
.tablename("vertexVectors") // indicate the name of the table in which the data should be stored
.overwrite(true) // indicate that if there is a table with the same name, it will be overwritten (truncated)
.store();Inferring Embeddings Using
Python
vertexVectors = model.infer_embeddings(fullGraph,fullGraph.getVertices()).flattenAll()
vertexVectors.write().db(username="user", password="password", jdbc_url="jdbcUrl",
name="vertex vectors", "tablename", overwrite=True)
Parent topic: Inferring Embeddings for a Supervised GraphWise Model