Skip to content

Commit

Permalink
Add tensorflow example
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos committed Apr 28, 2023
1 parent aa07580 commit 7f43069
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/src/models/embeddings/tensorflow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-disable import/no-extraneous-dependencies */

import "@tensorflow/tfjs-backend-cpu";
import { Document } from "langchain/document";
import { TensorFlowEmbeddings } from "langchain/embeddings/tensorflow";
import { MemoryVectorStore } from "langchain/vectorstores/memory";

const embeddings = new TensorFlowEmbeddings();
const store = new MemoryVectorStore(embeddings);

const documents = [
"A document",
"Some other piece of text",
"One more",
"And another",
];

await store.addDocuments(
documents.map((pageContent) => new Document({ pageContent }))
);

0 comments on commit 7f43069

Please sign in to comment.